Skip to content

Handle extend inside class << self for rank-N singletons#894

Draft
soutaro wants to merge 1 commit into
materialize-singleton-classesfrom
support-extend-in-singleton-class
Draft

Handle extend inside class << self for rank-N singletons#894
soutaro wants to merge 1 commit into
materialize-singleton-classesfrom
support-extend-in-singleton-class

Conversation

@soutaro

@soutaro soutaro commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
  • 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.

- 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>
@soutaro soutaro self-assigned this Jun 30, 2026
@amomchilov amomchilov changed the title Handle extend inside class << self for rank-N singletons Handle extend inside class << self for rank-N singletons Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant