rbs-inline 0.4.0 → 0.6.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.
@@ -6,18 +6,20 @@ module RBS
6
6
  module Members
7
7
  # @rbs!
8
8
  # type ruby = RubyDef | RubyAlias | RubyMixin | RubyAttr | RubyPublic | RubyPrivate
9
+ #
9
10
  # type rbs = RBSIvar | RBSEmbedded
11
+ #
10
12
  # type t = ruby | rbs
11
13
 
12
14
  class Base
13
- attr_reader :location #:: Prism::Location
15
+ attr_reader :location #: Prism::Location
14
16
 
15
17
  # @rbs location: Prism::Location
16
- def initialize(location) #:: void
18
+ def initialize(location) #: void
17
19
  @location = location
18
20
  end
19
21
 
20
- def start_line #:: Integer
22
+ def start_line #: Integer
21
23
  location.start_line
22
24
  end
23
25
  end
@@ -26,8 +28,8 @@ module RBS
26
28
  end
27
29
 
28
30
  class RubyDef < RubyBase
29
- attr_reader :node #:: Prism::DefNode
30
- attr_reader :comments #:: AnnotationParser::ParsingResult?
31
+ attr_reader :node #: Prism::DefNode
32
+ attr_reader :comments #: AnnotationParser::ParsingResult?
31
33
 
32
34
  # The visibility directly attached to the `def` node
33
35
  #
@@ -37,15 +39,17 @@ module RBS
37
39
  # def foo() end # <= nil
38
40
  # private def foo() end # <= :private
39
41
  # ```
40
- attr_reader :visibility #:: RBS::AST::Members::visibility?
42
+ attr_reader :visibility #: RBS::AST::Members::visibility?
41
43
 
42
- attr_reader :assertion #:: Annotations::Assertion?
44
+ # Assertion given at the end of the method name
45
+ #
46
+ attr_reader :assertion #: Annotations::TypeAssertion?
43
47
 
44
48
  # @rbs node: Prism::DefNode
45
49
  # @rbs comments: AnnotationParser::ParsingResult?
46
50
  # @rbs visibility: RBS::AST::Members::visibility?
47
- # @rbs assertion: Annotations::Assertion?
48
- def initialize(node, comments, visibility, assertion) #:: void
51
+ # @rbs assertion: Annotations::TypeAssertion?
52
+ def initialize(node, comments, visibility, assertion) #: void
49
53
  @node = node
50
54
  @comments = comments
51
55
  @visibility = visibility
@@ -55,39 +59,53 @@ module RBS
55
59
  end
56
60
 
57
61
  # Returns the name of the method
58
- def method_name #:: Symbol
62
+ def method_name #: Symbol
59
63
  node.name
60
64
  end
61
65
 
62
- def method_type_annotations #:: Array[Annotations::Assertion]
66
+ # Returns `nil` if no `@rbs METHOD-TYPE` or `#:` annotation is given
67
+ #
68
+ # Returns an empty array if only `...` method type is given.
69
+ #
70
+ def annotated_method_types #: Array[MethodType]?
63
71
  if comments
64
- comments.annotations.select do |annotation|
65
- annotation.is_a?(Annotations::Assertion) && annotation.type.is_a?(MethodType)
66
- end #: Array[Annotations::Assertion]
67
- else
68
- []
72
+ method_type_annotations = comments.each_annotation.select do |annotation|
73
+ annotation.is_a?(Annotations::MethodTypeAssertion) || annotation.is_a?(Annotations::Method) || annotation.is_a?(Annotations::Dot3Assertion)
74
+ end
75
+
76
+ return nil if method_type_annotations.empty?
77
+
78
+ method_type_annotations.each_with_object([]) do |annotation, method_types| #$ Array[MethodType]
79
+ case annotation
80
+ when Annotations::MethodTypeAssertion
81
+ method_types << annotation.method_type
82
+ when Annotations::Method
83
+ annotation.each_method_type do
84
+ method_types << _1
85
+ end
86
+ end
87
+ end
69
88
  end
70
89
  end
71
90
 
72
- def return_type #:: Types::t?
91
+ def return_type #: Types::t?
73
92
  if assertion
74
- if assertion.type?
75
- return assertion.type?
76
- end
93
+ return assertion.type
77
94
  end
95
+
78
96
  if comments
79
- annot = comments.annotations.find {|annot| annot.is_a?(Annotations::ReturnType ) } #: Annotations::ReturnType?
97
+ annot = comments.each_annotation.find {|annot| annot.is_a?(Annotations::ReturnType ) } #: Annotations::ReturnType?
80
98
  if annot
81
99
  annot.type
82
100
  end
83
101
  end
84
102
  end
85
103
 
86
- def var_type_hash #:: Hash[Symbol, Types::t?]
104
+ def var_type_hash #: Hash[Symbol, Types::t?]
87
105
  types = {} #: Hash[Symbol, Types::t?]
88
106
 
89
107
  if comments
90
- comments.annotations.each do |annotation|
108
+ comments.each_annotation.each do |annotation|
91
109
  if annotation.is_a?(Annotations::VarType)
92
110
  name = annotation.name
93
111
  type = annotation.type
@@ -102,11 +120,42 @@ module RBS
102
120
  types
103
121
  end
104
122
 
105
- def method_overloads #:: Array[RBS::AST::Members::MethodDefinition::Overload]
106
- if !(annots = method_type_annotations).empty?
107
- annots.map do
108
- method_type = _1.type #: MethodType
123
+ def splat_param_type_annotation #: Annotations::SplatParamType?
124
+ if comments
125
+ comments.each_annotation.find do |annotation|
126
+ annotation.is_a?(Annotations::SplatParamType)
127
+ end #: Annotations::SplatParamType?
128
+ end
129
+ end
130
+
131
+ def double_splat_param_type_annotation #: Annotations::DoubleSplatParamType?
132
+ if comments
133
+ comments.each_annotation.find do |annotation|
134
+ annotation.is_a?(Annotations::DoubleSplatParamType)
135
+ end #: Annotations::DoubleSplatParamType?
136
+ end
137
+ end
109
138
 
139
+ def overloading? #: bool
140
+ if comments
141
+ comments.each_annotation do |annotation|
142
+ if annotation.is_a?(Annotations::Method)
143
+ return true if annotation.overloading
144
+ end
145
+ if annotation.is_a?(Annotations::Dot3Assertion)
146
+ return true
147
+ end
148
+ end
149
+ false
150
+ else
151
+ false
152
+ end
153
+ end
154
+
155
+ def method_overloads #: Array[RBS::AST::Members::MethodDefinition::Overload]
156
+ case
157
+ when method_types = annotated_method_types
158
+ method_types.map do |method_type|
110
159
  RBS::AST::Members::MethodDefinition::Overload.new(
111
160
  method_type: method_type,
112
161
  annotations: []
@@ -144,22 +193,15 @@ module RBS
144
193
  end
145
194
 
146
195
  if (rest = node.parameters.rest).is_a?(Prism::RestParameterNode)
147
- rest_type =
148
- if rest.name
149
- var_type_hash[rest.name]
150
- end
151
-
152
- if rest_type
153
- if rest_type.is_a?(Types::ClassInstance)
154
- if rest_type.name.name == :Array && rest_type.name.namespace.empty?
155
- rest_type = rest_type.args[0]
156
- end
157
- end
196
+ splat_param_type = splat_param_type_annotation
197
+
198
+ if splat_param_type && splat_param_type.type
199
+ splat_type = splat_param_type.type
158
200
  end
159
201
 
160
202
  rest_positionals = Types::Function::Param.new(
161
203
  name: rest.name,
162
- type: rest_type || Types::Bases::Any.new(location: nil),
204
+ type: splat_type || Types::Bases::Any.new(location: nil),
163
205
  location: nil
164
206
  )
165
207
  end
@@ -183,60 +225,31 @@ module RBS
183
225
  end
184
226
 
185
227
  if (kw_rest = node.parameters.keyword_rest).is_a?(Prism::KeywordRestParameterNode)
186
- rest_type =
187
- if kw_rest.name
188
- var_type_hash[kw_rest.name]
189
- end
190
-
191
- if rest_type
192
- if rest_type.is_a?(Types::ClassInstance)
193
- if rest_type.name.name == :Hash && rest_type.name.namespace.empty?
194
- rest_type = rest_type.args[1]
195
- end
196
- end
228
+ double_splat_param_type = double_splat_param_type_annotation
229
+
230
+ if double_splat_param_type && double_splat_param_type.type
231
+ double_splat_type = double_splat_param_type.type
197
232
  end
198
233
 
199
234
  rest_keywords = Types::Function::Param.new(
200
235
  name: kw_rest.name,
201
- type: rest_type || Types::Bases::Any.new(location: nil),
236
+ type: double_splat_type || Types::Bases::Any.new(location: nil),
202
237
  location: nil)
203
238
  end
204
239
 
205
240
  if node.parameters.block
206
- if (block_name = node.parameters.block.name) && (var_type = var_type_hash[block_name])
207
- if var_type.is_a?(Types::Optional)
208
- optional = true
209
- var_type = var_type.type
210
- else
211
- optional = false
212
- end
213
-
214
- if var_type.is_a?(Types::Proc)
215
- block = Types::Block.new(type: var_type.type, self_type: var_type.self_type, required: !optional)
216
- end
217
- else
218
- block = Types::Block.new(
219
- type: Types::UntypedFunction.new(return_type: Types::Bases::Any.new(location: nil)),
220
- required: false,
221
- self_type: nil
222
- )
223
- end
224
- end
225
- end
226
-
227
- if annotation = yields_annotation
228
- case annotation.block_type
229
- when Types::Block
230
- block = annotation.block_type
231
- else
232
241
  block = Types::Block.new(
233
242
  type: Types::UntypedFunction.new(return_type: Types::Bases::Any.new(location: nil)),
234
- required: !annotation.optional,
243
+ required: false,
235
244
  self_type: nil
236
245
  )
237
246
  end
238
247
  end
239
248
 
249
+ if type = block_type_annotation&.type
250
+ block = type
251
+ end
252
+
240
253
  [
241
254
  RBS::AST::Members::MethodDefinition::Overload.new(
242
255
  method_type: RBS::MethodType.new(
@@ -260,16 +273,11 @@ module RBS
260
273
  end
261
274
  end
262
275
 
263
- def method_annotations #:: Array[RBS::AST::Annotation]
276
+ def method_annotations #: Array[RBS::AST::Annotation]
264
277
  if comments
265
- comments.annotations.flat_map do |annotation|
278
+ comments.each_annotation.flat_map do |annotation|
266
279
  if annotation.is_a?(AST::Annotations::RBSAnnotation)
267
- annotation.contents.map do |string|
268
- RBS::AST::Annotation.new(
269
- string: string[3...-1] || "",
270
- location: nil
271
- )
272
- end
280
+ annotation.annotations
273
281
  else
274
282
  []
275
283
  end
@@ -279,44 +287,45 @@ module RBS
279
287
  end
280
288
  end
281
289
 
282
- def override_annotation #:: AST::Annotations::Override?
290
+ # Returns the `@rbs override` annotation
291
+ def override_annotation #: AST::Annotations::Override?
283
292
  if comments
284
- comments.annotations.find do |annotation|
293
+ comments.each_annotation.find do |annotation|
285
294
  annotation.is_a?(AST::Annotations::Override)
286
295
  end #: AST::Annotations::Override?
287
296
  end
288
297
  end
289
298
 
290
- def yields_annotation #:: AST::Annotations::Yields?
299
+ def block_type_annotation #: AST::Annotations::BlockType?
291
300
  if comments
292
- comments.annotations.find do |annotation|
293
- annotation.is_a?(AST::Annotations::Yields)
294
- end #: AST::Annotations::Yields?
301
+ comments.each_annotation.find do |annotation|
302
+ annotation.is_a?(AST::Annotations::BlockType)
303
+ end #: AST::Annotations::BlockType?
295
304
  end
296
305
  end
297
306
  end
298
307
 
299
308
  class RubyAlias < RubyBase
300
- attr_reader :node #:: Prism::AliasMethodNode
301
- attr_reader :comments #:: AnnotationParser::ParsingResult?
309
+ attr_reader :node #: Prism::AliasMethodNode
310
+ attr_reader :comments #: AnnotationParser::ParsingResult?
302
311
 
303
312
  # @rbs node: Prism::AliasMethodNode
304
313
  # @rbs comments: AnnotationParser::ParsingResult?
305
- def initialize(node, comments)
314
+ def initialize(node, comments) #: void
306
315
  @node = node
307
316
  @comments = comments
308
317
 
309
318
  super(node.location)
310
319
  end
311
320
 
312
- # @rbs returns Symbol -- the name of *old* method
321
+ # @rbs return: Symbol -- the name of *old* method
313
322
  def old_name
314
323
  raise unless node.old_name.is_a?(Prism::SymbolNode)
315
324
  value = node.old_name.value or raise
316
325
  value.to_sym
317
326
  end
318
327
 
319
- # @rbs returns Symbol -- the name of *new* method
328
+ # @rbs return: Symbol -- the name of *new* method
320
329
  def new_name
321
330
  raise unless node.new_name.is_a?(Prism::SymbolNode)
322
331
  value = node.new_name.value or raise
@@ -328,18 +337,18 @@ module RBS
328
337
  include Declarations::ConstantUtil
329
338
 
330
339
  # CallNode that calls `include`, `prepend`, and `extend` method
331
- attr_reader :node #:: Prism::CallNode
340
+ attr_reader :node #: Prism::CallNode
332
341
 
333
342
  # Comments attached to the call node
334
- attr_reader :comments #:: AnnotationParser::ParsingResult?
343
+ attr_reader :comments #: AnnotationParser::ParsingResult?
335
344
 
336
345
  # Possible following type application annotation
337
- attr_reader :application #:: Annotations::Application?
346
+ attr_reader :application #: Annotations::Application?
338
347
 
339
348
  # @rbs node: Prism::CallNode
340
349
  # @rbs comments: AnnotationParser::ParsingResult?
341
350
  # @rbs application: Annotations::Application?
342
- # @rbs returns void
351
+ # @rbs return: void
343
352
  def initialize(node, comments, application)
344
353
  super(node.location)
345
354
 
@@ -348,7 +357,7 @@ module RBS
348
357
  @application = application
349
358
  end
350
359
 
351
- # @rbs returns ::RBS::AST::Members::Include
360
+ # @rbs return: ::RBS::AST::Members::Include
352
361
  # | ::RBS::AST::Members::Extend
353
362
  # | ::RBS::AST::Members::Prepend
354
363
  # | nil
@@ -397,14 +406,14 @@ module RBS
397
406
  end
398
407
 
399
408
  class RubyAttr < RubyBase
400
- attr_reader :node #:: Prism::CallNode
401
- attr_reader :comments #:: AnnotationParser::ParsingResult?
402
- attr_reader :assertion #:: Annotations::Assertion?
409
+ attr_reader :node #: Prism::CallNode
410
+ attr_reader :comments #: AnnotationParser::ParsingResult?
411
+ attr_reader :assertion #: Annotations::TypeAssertion?
403
412
 
404
413
  # @rbs node: Prism::CallNode
405
414
  # @rbs comments: AnnotationParser::ParsingResult?
406
- # @rbs assertion: Annotations::Assertion?
407
- # @rbs returns void
415
+ # @rbs assertion: Annotations::TypeAssertion?
416
+ # @rbs return: void
408
417
  def initialize(node, comments, assertion)
409
418
  super(node.location)
410
419
 
@@ -416,7 +425,7 @@ module RBS
416
425
  # @rbs return Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
417
426
  def rbs
418
427
  if comments
419
- comment = RBS::AST::Comment.new(string: comments.content, location: nil)
428
+ comment = RBS::AST::Comment.new(string: comments.content(trim: true), location: nil)
420
429
  end
421
430
 
422
431
  klass =
@@ -461,7 +470,7 @@ module RBS
461
470
  #
462
471
  # Returns `untyped` when not annotated.
463
472
  #
464
- def attribute_type #:: Types::t
473
+ def attribute_type #: Types::t
465
474
  type = assertion&.type
466
475
  raise if type.is_a?(MethodType)
467
476
 
@@ -472,10 +481,10 @@ module RBS
472
481
  # `private` call without arguments
473
482
  #
474
483
  class RubyPrivate < RubyBase
475
- attr_reader :node #:: Prism::CallNode
484
+ attr_reader :node #: Prism::CallNode
476
485
 
477
486
  # @rbs node: Prism::CallNode
478
- def initialize(node) #:: void
487
+ def initialize(node) #: void
479
488
  super(node.location)
480
489
  @node = node
481
490
  end
@@ -484,10 +493,10 @@ module RBS
484
493
  # `public` call without arguments
485
494
  #
486
495
  class RubyPublic < RubyBase
487
- attr_reader :node #:: Prism::CallNode
496
+ attr_reader :node #: Prism::CallNode
488
497
 
489
498
  # @rbs node: Prism::CallNode
490
- def initialize(node) #:: void
499
+ def initialize(node) #: void
491
500
  super(node.location)
492
501
  @node = node
493
502
  end
@@ -497,20 +506,20 @@ module RBS
497
506
  end
498
507
 
499
508
  class RBSIvar < RBSBase
500
- attr_reader :annotation #:: Annotations::IvarType
509
+ attr_reader :annotation #: Annotations::IvarType
501
510
 
502
- attr_reader :comment #:: AnnotationParser::ParsingResult
511
+ attr_reader :comment #: AnnotationParser::ParsingResult
503
512
 
504
513
  # @rbs comment: AnnotationParser::ParsingResult
505
514
  # @rbs annotation: Annotations::IvarType
506
- def initialize(comment, annotation) #:: void
515
+ def initialize(comment, annotation) #: void
507
516
  @comment = comment
508
517
  @annotation = annotation
509
518
 
510
519
  super(comment.comments[0].location)
511
520
  end
512
521
 
513
- def rbs #:: RBS::AST::Members::InstanceVariable | RBS::AST::Members::ClassInstanceVariable | nil
522
+ def rbs #: RBS::AST::Members::InstanceVariable | RBS::AST::Members::ClassInstanceVariable | nil
514
523
  if annotation.type
515
524
  if annotation.comment
516
525
  string = annotation.comment.delete_prefix("--").lstrip
@@ -537,13 +546,13 @@ module RBS
537
546
  end
538
547
 
539
548
  class RBSEmbedded < RBSBase
540
- attr_reader :annotation #:: Annotations::Embedded
549
+ attr_reader :annotation #: Annotations::Embedded
541
550
 
542
- attr_reader :comment #:: AnnotationParser::ParsingResult
551
+ attr_reader :comment #: AnnotationParser::ParsingResult
543
552
 
544
553
  # @rbs comment: AnnotationParser::ParsingResult
545
554
  # @rbs annotation: Annotations::Embedded
546
- def initialize(comment, annotation) #:: void
555
+ def initialize(comment, annotation) #: void
547
556
  @comment = comment
548
557
  @annotation = annotation
549
558
 
@@ -554,7 +563,7 @@ module RBS
554
563
  #
555
564
  # Returns `RBS::ParsingError` when the `content` has syntax error.
556
565
  #
557
- def members #:: Array[RBS::AST::Members::t | RBS::AST::Declarations::t] | RBS::ParsingError
566
+ def members #: Array[RBS::AST::Members::t | RBS::AST::Declarations::t] | RBS::ParsingError
558
567
  source = <<~RBS
559
568
  module EmbeddedModuleTest
560
569
  #{annotation.content}
@@ -3,26 +3,27 @@
3
3
  module RBS
4
4
  module Inline
5
5
  module AST
6
- class Tree
7
- # @rbs!
8
- # type token = [Symbol, String]
9
- # type tree = token | Tree | Types::t | MethodType | nil
6
+ # @rbs!
7
+ # type token = [Symbol, String]
8
+ #
9
+ # type tree = token | Tree | Types::t | MethodType | nil
10
10
 
11
- attr_reader :trees #:: Array[tree]
12
- attr_reader :type #:: Symbol
11
+ class Tree
12
+ attr_reader :trees #: Array[tree]
13
+ attr_reader :type #: Symbol
13
14
 
14
15
  # Children but without `tWHITESPACE` tokens
15
- attr_reader :non_trivia_trees #:: Array[tree]
16
+ attr_reader :non_trivia_trees #: Array[tree]
16
17
 
17
18
  # @rbs type: Symbol
18
- def initialize(type)
19
+ def initialize(type) #: void
19
20
  @type = type
20
21
  @trees = []
21
22
  @non_trivia_trees = []
22
23
  end
23
24
 
24
25
  # @rbs tok: tree
25
- # @rbs returns self
26
+ # @rbs return: self
26
27
  def <<(tok)
27
28
  trees << tok
28
29
  unless tok.is_a?(Array) && tok[0] == :tWHITESPACE
@@ -32,7 +33,7 @@ module RBS
32
33
  end
33
34
 
34
35
  # Returns the source code associated to the tree
35
- def to_s #:: String
36
+ def to_s #: String
36
37
  buf = +""
37
38
 
38
39
  trees.each do |tree|
@@ -51,12 +52,26 @@ module RBS
51
52
  buf
52
53
  end
53
54
 
55
+ # Returns `true` if token at the given index is of the given type
56
+ def token?(type, at:)
57
+ if tok = nth_token?(at)
58
+ tok[0] == type
59
+ end
60
+ end
61
+
62
+ # Returns `true` if tree at the given index is of the given type
63
+ def tree?(type, at:)
64
+ if tree = nth_tree?(at)
65
+ tree.type == type
66
+ end
67
+ end
68
+
54
69
  # Returns n-th token from the children
55
70
  #
56
71
  # Raises if the value is not a token or nil.
57
72
  #
58
73
  # @rbs index: Integer
59
- # @rbs returns token?
74
+ # @rbs return: token?
60
75
  def nth_token(index)
61
76
  tok = non_trivia_trees[index]
62
77
  case tok
@@ -72,7 +87,7 @@ module RBS
72
87
  # Returns `nil` if the value is not a token.
73
88
  #
74
89
  # @rbs index: Integer
75
- # @rbs returns token?
90
+ # @rbs return: token?
76
91
  def nth_token?(index)
77
92
  tok = non_trivia_trees[index]
78
93
  case tok
@@ -88,7 +103,7 @@ module RBS
88
103
  # Raises if the value is not token.
89
104
  #
90
105
  # @rbs index: Integer
91
- # @rbs returns token
106
+ # @rbs return: token
92
107
  def nth_token!(index)
93
108
  nth_token(index) || raise
94
109
  end
@@ -98,7 +113,7 @@ module RBS
98
113
  # Raises if the value is not a tree or nil.
99
114
  #
100
115
  # @rbs index: Integer
101
- # @rbs returns Tree?
116
+ # @rbs return: Tree?
102
117
  def nth_tree(index)
103
118
  tok = non_trivia_trees[index]
104
119
  case tok
@@ -114,7 +129,7 @@ module RBS
114
129
  # Returns `nil` if the value is not a tree or nil.
115
130
  #
116
131
  # @rbs index: Integer
117
- # @rbs returns Tree?
132
+ # @rbs return: Tree?
118
133
  def nth_tree?(index)
119
134
  tok = non_trivia_trees[index]
120
135
  case tok
@@ -130,7 +145,7 @@ module RBS
130
145
  # Raises if the value is not a tree.
131
146
  #
132
147
  # @rbs index: Integer
133
- # @rbs returns Tree
148
+ # @rbs return: Tree
134
149
  def nth_tree!(index)
135
150
  nth_tree(index) || raise
136
151
  end
@@ -141,7 +156,7 @@ module RBS
141
156
  # Raises if the value is not a type or nil.
142
157
  #
143
158
  # @rbs index: Integer
144
- # @rbs returns Types::t?
159
+ # @rbs return: Types::t?
145
160
  def nth_type(index)
146
161
  tok = non_trivia_trees[index]
147
162
  case tok
@@ -157,7 +172,7 @@ module RBS
157
172
  # Returns `nil` if the value is not a type.
158
173
  #
159
174
  # @rbs index: Integer
160
- # @rbs returns Types::t?
175
+ # @rbs return: Types::t?
161
176
  def nth_type?(index)
162
177
  tok = non_trivia_trees[index]
163
178
  case tok
@@ -173,7 +188,7 @@ module RBS
173
188
  # Raises if the value is not a type.
174
189
  #
175
190
  # @rbs index: Integer
176
- # @rbs returns Types::t
191
+ # @rbs return: Types::t
177
192
  def nth_type!(index)
178
193
  nth_type(index) || raise
179
194
  end
@@ -183,7 +198,7 @@ module RBS
183
198
  # Raises if the value is not a method type or `nil`.
184
199
  #
185
200
  # @rbs index: Integer
186
- # @rbs returns MethodType?
201
+ # @rbs return: MethodType?
187
202
  def nth_method_type(index)
188
203
  tok = non_trivia_trees[index]
189
204
  case tok
@@ -199,7 +214,7 @@ module RBS
199
214
  # Returns `nil` if the value is not a method type.
200
215
  #
201
216
  # @rbs index: Integer
202
- # @rbs returns MethodType?
217
+ # @rbs return: MethodType?
203
218
  def nth_method_type?(index)
204
219
  tok = non_trivia_trees[index]
205
220
  case tok
@@ -215,7 +230,7 @@ module RBS
215
230
  # Raises if the value is not a method tree.
216
231
  #
217
232
  # @rbs index: Integer
218
- # @rbs returns MethodType
233
+ # @rbs return: MethodType
219
234
  def nth_method_type!(index)
220
235
  nth_method_type(index) || raise
221
236
  end