Describe the bug
Sorbet runtime doesn't support you using sig on method_added and singleton_method_added.
It is not a static error (Sorbet.run), but it is an error at runtime:
https://github.com/sorbet/sorbet/blob/234fef89444438a2e152d5658c8588b1d80db229/gems/sorbet-runtime/lib/types/private/methods/_methods.rb#L221-L226
Putting a sig on method_added is not supported (sorbet-runtime uses this method internally to perform sig validation logic)
RBS doesn't have to have this limitation, since it doesn't need this runtime support.
To Reproduce
Spoom version: '1.7.11'
Steps to reproduce the behavior:
-
Add an RBS signature to an implementation of method_added or singleton_method_added, e.g.
class Demo
class << self
extend T::Sig
# @override
#: (Symbol) -> void
def method_added(m)
super
end
# @override
#: (Symbol) -> void
def singleton_method_added(m)
super
end
end
end
-
Translate the file with Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sigs (like Tapioca does)
-
Execute the translated file
Expected behavior
No crash.
Workaround
Mark the signatures with @without_runtime
class Demo
class << self
extend T::Sig
# @override
+ # @without_runtime
#: (Symbol) -> void
def method_added(m)
super
end
# @override
+ # @without_runtime
#: (Symbol) -> void
def singleton_method_added(m)
super
end
end
end
Potential solution
- Add a special case to skip translation for every
method_added and singleton_method_added
- Similarly (but more regular), treat each such method as if it were tagged
@without_runtime
Describe the bug
Sorbet runtime doesn't support you using
sigonmethod_addedandsingleton_method_added.It is not a static error (Sorbet.run), but it is an error at runtime:
https://github.com/sorbet/sorbet/blob/234fef89444438a2e152d5658c8588b1d80db229/gems/sorbet-runtime/lib/types/private/methods/_methods.rb#L221-L226
RBS doesn't have to have this limitation, since it doesn't need this runtime support.
To Reproduce
Spoom version: '1.7.11'
Steps to reproduce the behavior:
Add an RBS signature to an implementation of
method_addedorsingleton_method_added, e.g.Translate the file with
Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sigs(like Tapioca does)Execute the translated file
Expected behavior
No crash.
Workaround
Mark the signatures with
@without_runtimeclass Demo class << self extend T::Sig # @override + # @without_runtime #: (Symbol) -> void def method_added(m) super end # @override + # @without_runtime #: (Symbol) -> void def singleton_method_added(m) super end end endPotential solution
method_addedandsingleton_method_added@without_runtime