Merged
Conversation
Previously, calling a method defined in a parent class on a child class instance (e.g., Dog.new.speak where speak is defined in Animal) produced a false positive "undefined method" error. This is because the method resolution order (MRO) did not walk the superclass chain for user-defined classes. This commit introduces a superclass_map in GlobalEnv that records parent-child relationships at class definition time, and extends the MRO fallback chain to walk the superclass hierarchy including each ancestor's included modules. Circular inheritance is safely handled via a visited set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c4a83b5 to
7138eb5
Compare
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.
Why
When a child class inherits from a parent class (e.g.,
class Dog < Animal), calling a method defined in the parent on a child instance (Dog.new.speak) currently produces a false positive "undefined method" error. This is because the method resolution order (MRO) does not walk the user-defined superclass chain. This is one of the most common Ruby patterns and a significant source of false positives.Changes
superclass_maptoGlobalEnvand record parent-child relationships inenter_class()ResolutionContextto aggregate resolution parameters for future extensibilityfallback_chain()to walk the superclass chain with circular inheritance protectionStruct.new(:name)) that cannot be trackedChecked
cd core && cargo test --lib— all tests passbundle exec rake test— all tests pass🤖 Generated with Claude Code