File tree Expand file tree Collapse file tree
lib/spoom/sorbet/translate
test/spoom/sorbet/translate Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ def rewrite_def(def_node, comments)
139139
140140 apply_member_annotations ( comments . method_annotations , sig )
141141
142+ # Sorbet runtime doesn't support `sig` on `method_added` or
143+ # `singleton_method_added`, so we always use `without_runtime` for them.
144+ if def_node . name == :method_added || def_node . name == :singleton_method_added
145+ sig . without_runtime = true
146+ end
147+
142148 @rewriter << Source ::Replace . new (
143149 signature . location . start_offset ,
144150 signature . location . end_offset ,
Original file line number Diff line number Diff line change @@ -124,6 +124,36 @@ def foo; end
124124 RB
125125 end
126126
127+ def test_translate_to_rbi_method_added_is_always_without_runtime
128+ contents = <<~RB
129+ class A
130+ class << self
131+ # @override
132+ #: (Symbol) -> void
133+ def method_added(m); end
134+
135+ # @override
136+ #: (Symbol) -> void
137+ def singleton_method_added(m); end
138+ end
139+ end
140+ RB
141+
142+ assert_equal ( <<~RB , rbs_comments_to_sorbet_sigs ( contents ) )
143+ class A
144+ class << self
145+ # @override
146+ T::Sig::WithoutRuntime.sig { override.params(m: Symbol).void }
147+ def method_added(m); end
148+
149+ # @override
150+ T::Sig::WithoutRuntime.sig { override.params(m: Symbol).void }
151+ def singleton_method_added(m); end
152+ end
153+ end
154+ RB
155+ end
156+
127157 def test_translate_to_rbi_singleton_method_sigs
128158 contents = <<~RB
129159 class A
You can’t perform that action at this time.
0 commit comments