diff --git a/lib/rbs/ast/ruby/annotations.rb b/lib/rbs/ast/ruby/annotations.rb index f8f0bed24..9c3ee0bc8 100644 --- a/lib/rbs/ast/ruby/annotations.rb +++ b/lib/rbs/ast/ruby/annotations.rb @@ -274,6 +274,15 @@ def map_type_name(&block) comment_location: comment_location ) #: self end + + def type_fingerprint + [ + "annots/param_type", + name_location.source, + param_type.to_s, + comment_location&.source + ] + end end class SplatParamTypeAnnotation < Base @@ -299,6 +308,15 @@ def map_type_name(&block) comment_location: comment_location ) #: self end + + def type_fingerprint + [ + "annots/splat_param_type", + name_location&.source, + param_type.to_s, + comment_location&.source + ] + end end class DoubleSplatParamTypeAnnotation < Base @@ -324,6 +342,15 @@ def map_type_name(&block) comment_location: comment_location ) #: self end + + def type_fingerprint + [ + "annots/double_splat_param_type", + name_location&.source, + param_type.to_s, + comment_location&.source + ] + end end class BlockParamTypeAnnotation < Base @@ -365,6 +392,16 @@ def optional? def required? !optional? end + + def type_fingerprint + [ + "annots/block_param_type", + name_location&.source, + type.to_s, + optional? ? "optional" : "required", + comment_location&.source + ] + end end end end diff --git a/lib/rbs/ast/ruby/members.rb b/lib/rbs/ast/ruby/members.rb index f035d6787..878baa39b 100644 --- a/lib/rbs/ast/ruby/members.rb +++ b/lib/rbs/ast/ruby/members.rb @@ -275,7 +275,7 @@ def type_fingerprint return_type_annotation&.type_fingerprint, all_param_annotations.map do |param| case param - when Annotations::ParamTypeAnnotation + when Annotations::Base param.type_fingerprint else param diff --git a/sig/ast/ruby/annotations.rbs b/sig/ast/ruby/annotations.rbs index 59be65bc5..ac3c25e88 100644 --- a/sig/ast/ruby/annotations.rbs +++ b/sig/ast/ruby/annotations.rbs @@ -257,6 +257,8 @@ module RBS def map_type_name: () { (TypeName) -> TypeName } -> self + def type_fingerprint: () -> untyped + %a{pure} def name: () -> Symbol end @@ -302,6 +304,8 @@ module RBS def map_type_name: () { (TypeName) -> TypeName } -> self + def type_fingerprint: () -> untyped + %a{pure} def name: () -> Symbol? end @@ -347,6 +351,8 @@ module RBS def map_type_name: () { (TypeName) -> TypeName } -> self + def type_fingerprint: () -> untyped + %a{pure} def name: () -> Symbol? end @@ -401,6 +407,8 @@ module RBS def map_type_name: () { (TypeName) -> TypeName } -> self + def type_fingerprint: () -> untyped + %a{pure} def name: () -> Symbol? def optional?: () -> bool