Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions lib/rbs/ast/ruby/annotations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rbs/ast/ruby/members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions sig/ast/ruby/annotations.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ module RBS

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

def type_fingerprint: () -> untyped

%a{pure}
def name: () -> Symbol
end
Expand Down Expand Up @@ -302,6 +304,8 @@ module RBS

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

def type_fingerprint: () -> untyped

%a{pure}
def name: () -> Symbol?
end
Expand Down Expand Up @@ -347,6 +351,8 @@ module RBS

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

def type_fingerprint: () -> untyped

%a{pure}
def name: () -> Symbol?
end
Expand Down Expand Up @@ -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
Expand Down