@@ -67,12 +67,17 @@ def maybe_translate_assertion(node)
6767
6868 start_offset = node . location . start_offset
6969 end_offset = node . location . end_offset
70- @rewriter << Source ::Replace . new ( start_offset , end_offset - 1 , "#{ dedent_value ( node , value ) } #{ rbs_annotation } " )
70+
71+ @rewriter << if node . name == :bind
72+ Source ::Replace . new ( start_offset , end_offset - 1 , rbs_annotation )
73+ else
74+ Source ::Replace . new ( start_offset , end_offset - 1 , "#{ dedent_value ( node , value ) } #{ rbs_annotation } " )
75+ end
7176
7277 true
7378 end
7479
75- #: (Prism::CallNode) -> void
80+ #: (Prism::CallNode) -> String
7681 def build_rbs_annotation ( call )
7782 case call . name
7883 when :let
@@ -83,6 +88,10 @@ def build_rbs_annotation(call)
8388 srb_type = call . arguments &.arguments &.last #: as !nil
8489 rbs_type = RBI ::Type . parse_node ( srb_type ) . rbs_string
8590 "#: as #{ rbs_type } "
91+ when :bind
92+ srb_type = call . arguments &.arguments &.last #: as !nil
93+ rbs_type = RBI ::Type . parse_node ( srb_type ) . rbs_string
94+ "#: self as #{ rbs_type } "
8695 when :must
8796 "#: as !nil"
8897 when :unsafe
@@ -113,6 +122,8 @@ def t_annotation?(node)
113122 case node . name
114123 when :let , :cast
115124 return node . arguments &.arguments &.size == 2
125+ when :bind
126+ return node . arguments &.arguments &.size == 2 && node . arguments &.arguments &.first . is_a? ( Prism ::SelfNode )
116127 when :must , :unsafe
117128 return node . arguments &.arguments &.size == 1
118129 end
0 commit comments