Skip to content

Commit edf297a

Browse files
authored
Merge pull request #2879 from ruby/fix-inlines
Add `#type_fingerprint` methods
2 parents ca70db7 + 0225595 commit edf297a

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

lib/rbs/ast/ruby/annotations.rb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ def map_type_name(&block)
274274
comment_location: comment_location
275275
) #: self
276276
end
277+
278+
def type_fingerprint
279+
[
280+
"annots/param_type",
281+
name_location.source,
282+
param_type.to_s,
283+
comment_location&.source
284+
]
285+
end
277286
end
278287

279288
class SplatParamTypeAnnotation < Base
@@ -299,6 +308,15 @@ def map_type_name(&block)
299308
comment_location: comment_location
300309
) #: self
301310
end
311+
312+
def type_fingerprint
313+
[
314+
"annots/splat_param_type",
315+
name_location&.source,
316+
param_type.to_s,
317+
comment_location&.source
318+
]
319+
end
302320
end
303321

304322
class DoubleSplatParamTypeAnnotation < Base
@@ -324,6 +342,15 @@ def map_type_name(&block)
324342
comment_location: comment_location
325343
) #: self
326344
end
345+
346+
def type_fingerprint
347+
[
348+
"annots/double_splat_param_type",
349+
name_location&.source,
350+
param_type.to_s,
351+
comment_location&.source
352+
]
353+
end
327354
end
328355

329356
class BlockParamTypeAnnotation < Base
@@ -365,6 +392,16 @@ def optional?
365392
def required?
366393
!optional?
367394
end
395+
396+
def type_fingerprint
397+
[
398+
"annots/block_param_type",
399+
name_location&.source,
400+
type.to_s,
401+
optional? ? "optional" : "required",
402+
comment_location&.source
403+
]
404+
end
368405
end
369406
end
370407
end

lib/rbs/ast/ruby/members.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def type_fingerprint
275275
return_type_annotation&.type_fingerprint,
276276
all_param_annotations.map do |param|
277277
case param
278-
when Annotations::ParamTypeAnnotation
278+
when Annotations::Base
279279
param.type_fingerprint
280280
else
281281
param

sig/ast/ruby/annotations.rbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ module RBS
257257

258258
def map_type_name: () { (TypeName) -> TypeName } -> self
259259

260+
def type_fingerprint: () -> untyped
261+
260262
%a{pure}
261263
def name: () -> Symbol
262264
end
@@ -302,6 +304,8 @@ module RBS
302304

303305
def map_type_name: () { (TypeName) -> TypeName } -> self
304306

307+
def type_fingerprint: () -> untyped
308+
305309
%a{pure}
306310
def name: () -> Symbol?
307311
end
@@ -347,6 +351,8 @@ module RBS
347351

348352
def map_type_name: () { (TypeName) -> TypeName } -> self
349353

354+
def type_fingerprint: () -> untyped
355+
350356
%a{pure}
351357
def name: () -> Symbol?
352358
end
@@ -401,6 +407,8 @@ module RBS
401407

402408
def map_type_name: () { (TypeName) -> TypeName } -> self
403409

410+
def type_fingerprint: () -> untyped
411+
404412
%a{pure} def name: () -> Symbol?
405413

406414
def optional?: () -> bool

0 commit comments

Comments
 (0)