rbi 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/rbi/type.rb CHANGED
@@ -15,23 +15,23 @@ module RBI
15
15
  #
16
16
  # It can also be a qualified name like `::Foo` or `Foo::Bar`.
17
17
  class Simple < Type
18
- extend T::Sig
19
-
20
- sig { returns(String) }
18
+ #: String
21
19
  attr_reader :name
22
20
 
23
- sig { params(name: String).void }
21
+ #: (String name) -> void
24
22
  def initialize(name)
25
23
  super()
26
24
  @name = name
27
25
  end
28
26
 
29
- sig { override.params(other: BasicObject).returns(T::Boolean) }
27
+ # @override
28
+ #: (BasicObject other) -> bool
30
29
  def ==(other)
31
30
  Simple === other && @name == other.name
32
31
  end
33
32
 
34
- sig { override.returns(String) }
33
+ # @override
34
+ #: -> String
35
35
  def to_rbi
36
36
  @name
37
37
  end
@@ -41,14 +41,14 @@ module RBI
41
41
 
42
42
  # `T.anything`.
43
43
  class Anything < Type
44
- extend T::Sig
45
-
46
- sig { override.params(other: BasicObject).returns(T::Boolean) }
44
+ # @override
45
+ #: (BasicObject other) -> bool
47
46
  def ==(other)
48
47
  Anything === other
49
48
  end
50
49
 
51
- sig { override.returns(String) }
50
+ # @override
51
+ #: -> String
52
52
  def to_rbi
53
53
  "T.anything"
54
54
  end
@@ -56,14 +56,14 @@ module RBI
56
56
 
57
57
  # `T.attached_class`.
58
58
  class AttachedClass < Type
59
- extend T::Sig
60
-
61
- sig { override.params(other: BasicObject).returns(T::Boolean) }
59
+ # @override
60
+ #: (BasicObject other) -> bool
62
61
  def ==(other)
63
62
  AttachedClass === other
64
63
  end
65
64
 
66
- sig { override.returns(String) }
65
+ # @override
66
+ #: -> String
67
67
  def to_rbi
68
68
  "T.attached_class"
69
69
  end
@@ -71,14 +71,14 @@ module RBI
71
71
 
72
72
  # `T::Boolean`.
73
73
  class Boolean < Type
74
- extend T::Sig
75
-
76
- sig { override.params(other: BasicObject).returns(T::Boolean) }
74
+ # @override
75
+ #: (BasicObject other) -> bool
77
76
  def ==(other)
78
77
  Boolean === other
79
78
  end
80
79
 
81
- sig { override.returns(String) }
80
+ # @override
81
+ #: -> String
82
82
  def to_rbi
83
83
  "T::Boolean"
84
84
  end
@@ -86,14 +86,14 @@ module RBI
86
86
 
87
87
  # `T.noreturn`.
88
88
  class NoReturn < Type
89
- extend T::Sig
90
-
91
- sig { override.params(other: BasicObject).returns(T::Boolean) }
89
+ # @override
90
+ #: (BasicObject other) -> bool
92
91
  def ==(other)
93
92
  NoReturn === other
94
93
  end
95
94
 
96
- sig { override.returns(String) }
95
+ # @override
96
+ #: -> String
97
97
  def to_rbi
98
98
  "T.noreturn"
99
99
  end
@@ -101,14 +101,14 @@ module RBI
101
101
 
102
102
  # `T.self_type`.
103
103
  class SelfType < Type
104
- extend T::Sig
105
-
106
- sig { override.params(other: BasicObject).returns(T::Boolean) }
104
+ # @override
105
+ #: (BasicObject other) -> bool
107
106
  def ==(other)
108
107
  SelfType === other
109
108
  end
110
109
 
111
- sig { override.returns(String) }
110
+ # @override
111
+ #: -> String
112
112
  def to_rbi
113
113
  "T.self_type"
114
114
  end
@@ -116,14 +116,14 @@ module RBI
116
116
 
117
117
  # `T.untyped`.
118
118
  class Untyped < Type
119
- extend T::Sig
120
-
121
- sig { override.params(other: BasicObject).returns(T::Boolean) }
119
+ # @override
120
+ #: (BasicObject other) -> bool
122
121
  def ==(other)
123
122
  Untyped === other
124
123
  end
125
124
 
126
- sig { override.returns(String) }
125
+ # @override
126
+ #: -> String
127
127
  def to_rbi
128
128
  "T.untyped"
129
129
  end
@@ -131,14 +131,14 @@ module RBI
131
131
 
132
132
  # `void`.
133
133
  class Void < Type
134
- extend T::Sig
135
-
136
- sig { override.params(other: BasicObject).returns(T::Boolean) }
134
+ # @override
135
+ #: (BasicObject other) -> bool
137
136
  def ==(other)
138
137
  Void === other
139
138
  end
140
139
 
141
- sig { override.returns(String) }
140
+ # @override
141
+ #: -> String
142
142
  def to_rbi
143
143
  "void"
144
144
  end
@@ -148,23 +148,23 @@ module RBI
148
148
 
149
149
  # The class of another type like `T::Class[Foo]`.
150
150
  class Class < Type
151
- extend T::Sig
152
-
153
- sig { returns(Type) }
151
+ #: Type
154
152
  attr_reader :type
155
153
 
156
- sig { params(type: Type).void }
154
+ #: (Type type) -> void
157
155
  def initialize(type)
158
156
  super()
159
157
  @type = type
160
158
  end
161
159
 
162
- sig { override.params(other: BasicObject).returns(T::Boolean) }
160
+ # @override
161
+ #: (BasicObject other) -> bool
163
162
  def ==(other)
164
163
  Class === other && @type == other.type
165
164
  end
166
165
 
167
- sig { override.returns(String) }
166
+ # @override
167
+ #: -> String
168
168
  def to_rbi
169
169
  "T::Class[#{@type}]"
170
170
  end
@@ -172,27 +172,27 @@ module RBI
172
172
 
173
173
  # The singleton class of another type like `T.class_of(Foo)`.
174
174
  class ClassOf < Type
175
- extend T::Sig
176
-
177
- sig { returns(Simple) }
175
+ #: Simple
178
176
  attr_reader :type
179
177
 
180
- sig { returns(T.nilable(Type)) }
178
+ #: Type?
181
179
  attr_reader :type_parameter
182
180
 
183
- sig { params(type: Simple, type_parameter: T.nilable(Type)).void }
181
+ #: (Simple type, ?Type? type_parameter) -> void
184
182
  def initialize(type, type_parameter = nil)
185
183
  super()
186
184
  @type = type
187
185
  @type_parameter = type_parameter
188
186
  end
189
187
 
190
- sig { override.params(other: BasicObject).returns(T::Boolean) }
188
+ # @override
189
+ #: (BasicObject other) -> bool
191
190
  def ==(other)
192
191
  ClassOf === other && @type == other.type && @type_parameter == other.type_parameter
193
192
  end
194
193
 
195
- sig { override.returns(String) }
194
+ # @override
195
+ #: -> String
196
196
  def to_rbi
197
197
  if @type_parameter
198
198
  "T.class_of(#{@type.to_rbi})[#{@type_parameter.to_rbi}]"
@@ -204,23 +204,23 @@ module RBI
204
204
 
205
205
  # A type that can be `nil` like `T.nilable(String)`.
206
206
  class Nilable < Type
207
- extend T::Sig
208
-
209
- sig { returns(Type) }
207
+ #: Type
210
208
  attr_reader :type
211
209
 
212
- sig { params(type: Type).void }
210
+ #: (Type type) -> void
213
211
  def initialize(type)
214
212
  super()
215
213
  @type = type
216
214
  end
217
215
 
218
- sig { override.params(other: BasicObject).returns(T::Boolean) }
216
+ # @override
217
+ #: (BasicObject other) -> bool
219
218
  def ==(other)
220
219
  Nilable === other && @type == other.type
221
220
  end
222
221
 
223
- sig { override.returns(String) }
222
+ # @override
223
+ #: -> String
224
224
  def to_rbi
225
225
  "T.nilable(#{@type.to_rbi})"
226
226
  end
@@ -228,21 +228,21 @@ module RBI
228
228
 
229
229
  # A type that is composed of multiple types like `T.all(String, Integer)`.
230
230
  class Composite < Type
231
- extend T::Sig
232
231
  extend T::Helpers
233
232
 
234
233
  abstract!
235
234
 
236
- sig { returns(T::Array[Type]) }
235
+ #: Array[Type]
237
236
  attr_reader :types
238
237
 
239
- sig { params(types: T::Array[Type]).void }
238
+ #: (Array[Type] types) -> void
240
239
  def initialize(types)
241
240
  super()
242
241
  @types = types
243
242
  end
244
243
 
245
- sig { override.params(other: BasicObject).returns(T::Boolean) }
244
+ # @override
245
+ #: (BasicObject other) -> bool
246
246
  def ==(other)
247
247
  self.class === other && @types.sort_by(&:to_rbi) == other.types.sort_by(&:to_rbi)
248
248
  end
@@ -250,9 +250,8 @@ module RBI
250
250
 
251
251
  # A type that is intersection of multiple types like `T.all(String, Integer)`.
252
252
  class All < Composite
253
- extend T::Sig
254
-
255
- sig { override.returns(String) }
253
+ # @override
254
+ #: -> String
256
255
  def to_rbi
257
256
  "T.all(#{@types.map(&:to_rbi).join(", ")})"
258
257
  end
@@ -260,14 +259,13 @@ module RBI
260
259
 
261
260
  # A type that is union of multiple types like `T.any(String, Integer)`.
262
261
  class Any < Composite
263
- extend T::Sig
264
-
265
- sig { override.returns(String) }
262
+ # @override
263
+ #: -> String
266
264
  def to_rbi
267
265
  "T.any(#{@types.map(&:to_rbi).join(", ")})"
268
266
  end
269
267
 
270
- sig { returns(T::Boolean) }
268
+ #: -> bool
271
269
  def nilable?
272
270
  @types.any? { |type| type.nilable? || (type.is_a?(Simple) && type.name == "NilClass") }
273
271
  end
@@ -277,27 +275,27 @@ module RBI
277
275
 
278
276
  # A generic type like `T::Array[String]` or `T::Hash[Symbol, Integer]`.
279
277
  class Generic < Type
280
- extend T::Sig
281
-
282
- sig { returns(String) }
278
+ #: String
283
279
  attr_reader :name
284
280
 
285
- sig { returns(T::Array[Type]) }
281
+ #: Array[Type]
286
282
  attr_reader :params
287
283
 
288
- sig { params(name: String, params: Type).void }
284
+ #: (String name, *Type params) -> void
289
285
  def initialize(name, *params)
290
286
  super()
291
287
  @name = name
292
288
  @params = T.let(params, T::Array[Type])
293
289
  end
294
290
 
295
- sig { override.params(other: BasicObject).returns(T::Boolean) }
291
+ # @override
292
+ #: (BasicObject other) -> bool
296
293
  def ==(other)
297
294
  Generic === other && @name == other.name && @params == other.params
298
295
  end
299
296
 
300
- sig { override.returns(String) }
297
+ # @override
298
+ #: -> String
301
299
  def to_rbi
302
300
  "#{@name}[#{@params.map(&:to_rbi).join(", ")}]"
303
301
  end
@@ -305,23 +303,23 @@ module RBI
305
303
 
306
304
  # A type parameter like `T.type_parameter(:U)`.
307
305
  class TypeParameter < Type
308
- extend T::Sig
309
-
310
- sig { returns(Symbol) }
306
+ #: Symbol
311
307
  attr_reader :name
312
308
 
313
- sig { params(name: Symbol).void }
309
+ #: (Symbol name) -> void
314
310
  def initialize(name)
315
311
  super()
316
312
  @name = name
317
313
  end
318
314
 
319
- sig { override.params(other: BasicObject).returns(T::Boolean) }
315
+ # @override
316
+ #: (BasicObject other) -> bool
320
317
  def ==(other)
321
318
  TypeParameter === other && @name == other.name
322
319
  end
323
320
 
324
- sig { override.returns(String) }
321
+ # @override
322
+ #: -> String
325
323
  def to_rbi
326
324
  "T.type_parameter(#{@name.inspect})"
327
325
  end
@@ -331,23 +329,23 @@ module RBI
331
329
 
332
330
  # A tuple type like `[String, Integer]`.
333
331
  class Tuple < Type
334
- extend T::Sig
335
-
336
- sig { returns(T::Array[Type]) }
332
+ #: Array[Type]
337
333
  attr_reader :types
338
334
 
339
- sig { params(types: T::Array[Type]).void }
335
+ #: (Array[Type] types) -> void
340
336
  def initialize(types)
341
337
  super()
342
338
  @types = types
343
339
  end
344
340
 
345
- sig { override.params(other: BasicObject).returns(T::Boolean) }
341
+ # @override
342
+ #: (BasicObject other) -> bool
346
343
  def ==(other)
347
344
  Tuple === other && @types == other.types
348
345
  end
349
346
 
350
- sig { override.returns(String) }
347
+ # @override
348
+ #: -> String
351
349
  def to_rbi
352
350
  "[#{@types.map(&:to_rbi).join(", ")}]"
353
351
  end
@@ -355,23 +353,23 @@ module RBI
355
353
 
356
354
  # A shape type like `{name: String, age: Integer}`.
357
355
  class Shape < Type
358
- extend T::Sig
359
-
360
- sig { returns(T::Hash[T.any(String, Symbol), Type]) }
356
+ #: Hash[(String | Symbol), Type]
361
357
  attr_reader :types
362
358
 
363
- sig { params(types: T::Hash[T.any(String, Symbol), Type]).void }
359
+ #: (Hash[(String | Symbol), Type] types) -> void
364
360
  def initialize(types)
365
361
  super()
366
362
  @types = types
367
363
  end
368
364
 
369
- sig { override.params(other: BasicObject).returns(T::Boolean) }
365
+ # @override
366
+ #: (BasicObject other) -> bool
370
367
  def ==(other)
371
368
  Shape === other && @types.sort_by { |t| t.first.to_s } == other.types.sort_by { |t| t.first.to_s }
372
369
  end
373
370
 
374
- sig { override.returns(String) }
371
+ # @override
372
+ #: -> String
375
373
  def to_rbi
376
374
  if @types.empty?
377
375
  "{}"
@@ -385,18 +383,16 @@ module RBI
385
383
 
386
384
  # A proc type like `T.proc.void`.
387
385
  class Proc < Type
388
- extend T::Sig
389
-
390
- sig { returns(T::Hash[Symbol, Type]) }
386
+ #: Hash[Symbol, Type]
391
387
  attr_reader :proc_params
392
388
 
393
- sig { returns(Type) }
389
+ #: Type
394
390
  attr_reader :proc_returns
395
391
 
396
- sig { returns(T.nilable(Type)) }
392
+ #: Type?
397
393
  attr_reader :proc_bind
398
394
 
399
- sig { void }
395
+ #: -> void
400
396
  def initialize
401
397
  super
402
398
  @proc_params = T.let({}, T::Hash[Symbol, Type])
@@ -404,7 +400,8 @@ module RBI
404
400
  @proc_bind = T.let(nil, T.nilable(Type))
405
401
  end
406
402
 
407
- sig { override.params(other: BasicObject).returns(T::Boolean) }
403
+ # @override
404
+ #: (BasicObject other) -> bool
408
405
  def ==(other)
409
406
  return false unless Proc === other
410
407
  return false unless @proc_params == other.proc_params
@@ -414,31 +411,32 @@ module RBI
414
411
  true
415
412
  end
416
413
 
417
- sig { params(params: Type).returns(T.self_type) }
414
+ #: (**Type params) -> self
418
415
  def params(**params)
419
416
  @proc_params = params
420
417
  self
421
418
  end
422
419
 
423
- sig { params(type: T.untyped).returns(T.self_type) }
420
+ #: (untyped type) -> self
424
421
  def returns(type)
425
422
  @proc_returns = type
426
423
  self
427
424
  end
428
425
 
429
- sig { returns(T.self_type) }
426
+ #: -> self
430
427
  def void
431
428
  @proc_returns = RBI::Type.void
432
429
  self
433
430
  end
434
431
 
435
- sig { params(type: T.untyped).returns(T.self_type) }
432
+ #: (untyped type) -> self
436
433
  def bind(type)
437
434
  @proc_bind = type
438
435
  self
439
436
  end
440
437
 
441
- sig { override.returns(String) }
438
+ # @override
439
+ #: -> String
442
440
  def to_rbi
443
441
  rbi = +"T.proc"
444
442
 
@@ -466,14 +464,12 @@ module RBI
466
464
  # Type builder
467
465
 
468
466
  class << self
469
- extend T::Sig
470
-
471
467
  # Simple
472
468
 
473
469
  # Builds a simple type like `String` or `::Foo::Bar`.
474
470
  #
475
471
  # It raises a `NameError` if the name is not a valid Ruby class identifier.
476
- sig { params(name: String).returns(Simple) }
472
+ #: (String name) -> Simple
477
473
  def simple(name)
478
474
  # TODO: should we allow creating the instance anyway and move this to a `validate!` method?
479
475
  raise NameError, "Invalid type name: `#{name}`" unless valid_identifier?(name)
@@ -484,43 +480,43 @@ module RBI
484
480
  # Literals
485
481
 
486
482
  # Builds a type that represents `T.anything`.
487
- sig { returns(Anything) }
483
+ #: -> Anything
488
484
  def anything
489
485
  Anything.new
490
486
  end
491
487
 
492
488
  # Builds a type that represents `T.attached_class`.
493
- sig { returns(AttachedClass) }
489
+ #: -> AttachedClass
494
490
  def attached_class
495
491
  AttachedClass.new
496
492
  end
497
493
 
498
494
  # Builds a type that represents `T::Boolean`.
499
- sig { returns(Boolean) }
495
+ #: -> Boolean
500
496
  def boolean
501
497
  Boolean.new
502
498
  end
503
499
 
504
500
  # Builds a type that represents `T.noreturn`.
505
- sig { returns(NoReturn) }
501
+ #: -> NoReturn
506
502
  def noreturn
507
503
  NoReturn.new
508
504
  end
509
505
 
510
506
  # Builds a type that represents `T.self_type`.
511
- sig { returns(SelfType) }
507
+ #: -> SelfType
512
508
  def self_type
513
509
  SelfType.new
514
510
  end
515
511
 
516
512
  # Builds a type that represents `T.untyped`.
517
- sig { returns(Untyped) }
513
+ #: -> Untyped
518
514
  def untyped
519
515
  Untyped.new
520
516
  end
521
517
 
522
518
  # Builds a type that represents `void`.
523
- sig { returns(Void) }
519
+ #: -> Void
524
520
  def void
525
521
  Void.new
526
522
  end
@@ -528,13 +524,13 @@ module RBI
528
524
  # Composites
529
525
 
530
526
  # Builds a type that represents the class of another type like `T::Class[Foo]`.
531
- sig { params(type: Type).returns(Class) }
527
+ #: (Type type) -> Class
532
528
  def t_class(type)
533
529
  Class.new(type)
534
530
  end
535
531
 
536
532
  # Builds a type that represents the singleton class of another type like `T.class_of(Foo)`.
537
- sig { params(type: Simple, type_parameter: T.nilable(Type)).returns(ClassOf) }
533
+ #: (Simple type, ?Type? type_parameter) -> ClassOf
538
534
  def class_of(type, type_parameter = nil)
539
535
  ClassOf.new(type, type_parameter)
540
536
  end
@@ -543,7 +539,7 @@ module RBI
543
539
  #
544
540
  # Note that this method transforms types such as `T.nilable(T.untyped)` into `T.untyped`, so
545
541
  # it may return something other than a `RBI::Type::Nilable`.
546
- sig { params(type: Type).returns(Type) }
542
+ #: (Type type) -> Type
547
543
  def nilable(type)
548
544
  # TODO: should we move this logic to a `flatten!`, `normalize!` or `simplify!` method?
549
545
  return type if type.is_a?(Untyped)
@@ -559,7 +555,7 @@ module RBI
559
555
  #
560
556
  # Note that this method transforms types such as `T.all(String, String)` into `String`, so
561
557
  # it may return something other than a `All`.
562
- sig { params(type1: Type, type2: Type, types: Type).returns(Type) }
558
+ #: (Type type1, Type type2, *Type types) -> Type
563
559
  def all(type1, type2, *types)
564
560
  types = [type1, type2, *types]
565
561
 
@@ -586,7 +582,7 @@ module RBI
586
582
  #
587
583
  # Note that this method transforms types such as `T.any(String, NilClass)` into `T.nilable(String)`, so
588
584
  # it may return something other than a `Any`.
589
- sig { params(type1: Type, type2: Type, types: Type).returns(Type) }
585
+ #: (Type type1, Type type2, *Type types) -> Type
590
586
  def any(type1, type2, *types)
591
587
  types = [type1, type2, *types]
592
588
 
@@ -651,13 +647,13 @@ module RBI
651
647
  # Generics
652
648
 
653
649
  # Builds a type that represents a generic type like `T::Array[String]` or `T::Hash[Symbol, Integer]`.
654
- sig { params(name: String, params: T.any(Type, T::Array[Type])).returns(Generic) }
650
+ #: (String name, *(Type | Array[Type]) params) -> Generic
655
651
  def generic(name, *params)
656
652
  T.unsafe(Generic).new(name, *params.flatten)
657
653
  end
658
654
 
659
655
  # Builds a type that represents a type parameter like `T.type_parameter(:U)`.
660
- sig { params(name: Symbol).returns(TypeParameter) }
656
+ #: (Symbol name) -> TypeParameter
661
657
  def type_parameter(name)
662
658
  TypeParameter.new(name)
663
659
  end
@@ -665,13 +661,13 @@ module RBI
665
661
  # Tuples and shapes
666
662
 
667
663
  # Builds a type that represents a tuple type like `[String, Integer]`.
668
- sig { params(types: T.any(Type, T::Array[Type])).returns(Tuple) }
664
+ #: (*(Type | Array[Type]) types) -> Tuple
669
665
  def tuple(*types)
670
666
  Tuple.new(types.flatten)
671
667
  end
672
668
 
673
669
  # Builds a type that represents a shape type like `{name: String, age: Integer}`.
674
- sig { params(types: T::Hash[T.any(String, Symbol), Type]).returns(Shape) }
670
+ #: (?Hash[(String | Symbol), Type] types) -> Shape
675
671
  def shape(types = {})
676
672
  Shape.new(types)
677
673
  end
@@ -679,7 +675,7 @@ module RBI
679
675
  # Proc
680
676
 
681
677
  # Builds a type that represents a proc type like `T.proc.void`.
682
- sig { returns(Proc) }
678
+ #: -> Proc
683
679
  def proc
684
680
  Proc.new
685
681
  end
@@ -689,13 +685,13 @@ module RBI
689
685
 
690
686
  private
691
687
 
692
- sig { params(name: String).returns(T::Boolean) }
688
+ #: (String name) -> bool
693
689
  def valid_identifier?(name)
694
690
  Prism.parse("class self::#{name.delete_prefix("::")}; end").success?
695
691
  end
696
692
  end
697
693
 
698
- sig { void }
694
+ #: -> void
699
695
  def initialize
700
696
  @nilable = T.let(false, T::Boolean)
701
697
  end
@@ -709,7 +705,7 @@ module RBI
709
705
  # type.nilable.to_rbi # => "T.nilable(String)"
710
706
  # type.nilable.nilable.to_rbi # => "T.nilable(String)"
711
707
  # ```
712
- sig { returns(Type) }
708
+ #: -> Type
713
709
  def nilable
714
710
  Type.nilable(self)
715
711
  end
@@ -724,7 +720,7 @@ module RBI
724
720
  # type.non_nilable.to_rbi # => "String"
725
721
  # type.non_nilable.non_nilable.to_rbi # => "String"
726
722
  # ```
727
- sig { returns(Type) }
723
+ #: -> Type
728
724
  def non_nilable
729
725
  # TODO: Should this logic be moved into a builder method?
730
726
  case self
@@ -736,7 +732,7 @@ module RBI
736
732
  end
737
733
 
738
734
  # Returns whether the type is nilable.
739
- sig { returns(T::Boolean) }
735
+ #: -> bool
740
736
  def nilable?
741
737
  is_a?(Nilable)
742
738
  end
@@ -744,12 +740,13 @@ module RBI
744
740
  sig { abstract.params(other: BasicObject).returns(T::Boolean) }
745
741
  def ==(other); end
746
742
 
747
- sig { params(other: BasicObject).returns(T::Boolean) }
743
+ #: (BasicObject other) -> bool
748
744
  def eql?(other)
749
745
  self == other
750
746
  end
751
747
 
752
- sig { override.returns(Integer) }
748
+ # @override
749
+ #: -> Integer
753
750
  def hash
754
751
  to_rbi.hash
755
752
  end
@@ -757,7 +754,8 @@ module RBI
757
754
  sig { abstract.returns(String) }
758
755
  def to_rbi; end
759
756
 
760
- sig { override.returns(String) }
757
+ # @override
758
+ #: -> String
761
759
  def to_s
762
760
  to_rbi
763
761
  end