-
Notifications
You must be signed in to change notification settings - Fork 23
Description
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:
Putting a
sigonmethod_addedis not supported (sorbet-runtime uses this method internally to performsigvalidation 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_addedorsingleton_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
endPotential solution
- Add a special case to skip translation for every
method_addedandsingleton_method_added - Similarly (but more regular), treat each such method as if it were tagged
@without_runtime