Attribute definition on singleton should call singleton_method_added#8070
Merged
headius merged 4 commits intojruby:masterfrom Jan 19, 2024
Merged
Attribute definition on singleton should call singleton_method_added#8070headius merged 4 commits intojruby:masterfrom
headius merged 4 commits intojruby:masterfrom
Conversation
We were only calling method_added, which does not match CRuby behavior. This was the root cause of Shopify/ruby-lsp#1263.
These are only called in one place, but may be needed in the future if they should be called for other logic that undefines or removes methods.
1 task
If bound from a Java method, it almost certainly will have the wrong signature for Ruby calls to it, leading to arity and other errors when a singleton method or class method are defined on a Java proxy type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Shopify/ruby-lsp#1263 for background on this.
When defining an attribute (
attr,attr_reader,attr_writer,attr_accessor) on a metaclass or singleton object, we should be callingsingleton_method_added. Instead, we were callingmethod_added.The caused Shopify/ruby-lsp#1263 when an
attr_readerin a metaclass body did not consume a Sorbetsigset up for it.I've also factored out two other method hook cases in case they are needed other places in the future:
method_undefinedandmethod_removed.