Skip to content

Open enums (Strategy B): per-case method overrides, hierarchical subt…#653

Open
eliotmoss wants to merge 1 commit into
titzer:masterfrom
eliotmoss:open_enums3b_squashed
Open

Open enums (Strategy B): per-case method overrides, hierarchical subt…#653
eliotmoss wants to merge 1 commit into
titzer:masterfrom
eliotmoss:open_enums3b_squashed

Conversation

@eliotmoss
Copy link
Copy Markdown
Contributor

…ypes, fields, methods, squahed

Squashed snapshot of open_enums3b past master. Adds:

  • Open enum types with hierarchical subtypes (enum E.More { ... }), case _ defaults, DFS-assigned tag ranges for subtype matching, and qualified case access (E.More.C).
  • Per-case enum method overrides (Case { def m() ... }) via synthetic per-case VstClass / IrClass / RaClass — Strategy B. Cases without overrides share the parent RaClass (elision).
  • Subtype enum method overrides (enum E.More { ...; def m() ... }) with virtual dispatch through the root enum's mtable.
  • Subtype field redeclaration / addition (E.S(super, f: float), E.S(super), E.S { D(15) }) with multi-level inheritance.
  • EnumSetType for hierarchies (one set type per root, bit positions by DFS tag).
  • Enum method closures with proper boxing on JVM (Integer) and wasm-gc (i31ref); Oop/raw tag receiver convention switched per target via NormConfig.
  • Queue-based two-dimensional liveness (live cases x live virtuals -> live impls) and -compact-mtable=N optimization for compacting redundant mtable rows via tag->slot indirection.
  • JvmV3EnumGen M_ABSTRACT guard, SsaInliner enum NullCheck skip, and other backend fixes for v3i / x86 / x86-64 / jar / wasm / wasm-gc.
  • One master regression fix (lookupEnumExprMember VstField receiver), benchmarks (EnumScalability, EnumLiveness, EnumOverrides, EnumClosureBoxing), and the wasm bench runner.
  • Tutorial and grammar reference updates for open enums.

37/37 ci/Makefile configs pass 3809/3809 tests.

…ypes, fields, methods

Squashed snapshot of open_enums3b past master. Adds:

- Open enum types with hierarchical subtypes (`enum E.More { ... }`),
  `case _` defaults, DFS-assigned tag ranges for subtype matching,
  and qualified case access (`E.More.C`).
- Per-case enum method overrides (`Case { def m() ... }`) via
  synthetic per-case VstClass / IrClass / RaClass — Strategy B.
  Cases without overrides share the parent RaClass (elision).
- Subtype enum method overrides (`enum E.More { ...; def m() ... }`)
  with virtual dispatch through the root enum's mtable.
- Subtype field redeclaration / addition (`E.S(super, f: float)`,
  `E.S(super)`, `E.S { D(15) }`) with multi-level inheritance.
- `EnumSetType` for hierarchies (one set type per root, bit positions
  by DFS tag).
- Enum method closures with proper boxing on JVM (Integer) and
  wasm-gc (i31ref); Oop/raw tag receiver convention switched per
  target via NormConfig.
- Queue-based two-dimensional liveness (live cases x live virtuals -> live
  impls) and `-compact-mtable=N` optimization for compacting redundant
  mtable rows via tag->slot indirection.
- JvmV3EnumGen M_ABSTRACT guard, SsaInliner enum NullCheck skip,
  and other backend fixes for v3i / x86 / x86-64 / jar / wasm /
  wasm-gc.
- One master regression fix (lookupEnumExprMember VstField receiver),
  benchmarks (EnumScalability, EnumLiveness, EnumOverrides,
  EnumClosureBoxing), and the wasm bench runner.
- Tutorial and grammar reference updates for open enums.

37/37 ci/Makefile configs pass 3809/3809 tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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