Handle extend inside class << self for rank-N singletons#894
Draft
soutaro wants to merge 1 commit into
Draft
Conversation
- Linearize: drop the `!is_singleton_class` guard so an `extend M` written inside a `class << self` always creates that singleton's own singleton (the rank-2 `Foo::<Foo>::<<Foo>>`), with `M` mixed in as an ancestor. It was previously skipped for singleton classes. - Seed rank-N materialization from any singleton whose own `class << self` carries an `extend`: the extend mixes the module into that singleton's own singleton as an ancestor (mixins are never members), so the definition/member checks that detect explicit singletons miss it. Seeding here materializes the rank-`(N + 1)` singleton for every subclass too. - Add tests: rank-2 singleton for the extended class itself, and for a subclass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
extend inside class << self for rank-N singletons
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.
!is_singleton_classguard so anextend Mwritten inside aclass << selfalways creates that singleton's own singleton (the rank-2Foo::<Foo>::<<Foo>>), withMmixed in as an ancestor. It was previously skipped for singleton classes.class << selfcarries anextend: the extend mixes the module into that singleton's own singleton as an ancestor (mixins are never members), so the definition/member checks that detect explicit singletons miss it. Seeding here materializes the rank-(N + 1)singleton for every subclass too.