You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix cyclicity error for self-referential enum case
Fixes#11443
When an enum case references itself in a parent type (e.g.,
`case Nn extends Opt[Nothing] with Comparable[Nn.type]`), the
compiler previously reported a cyclic reference error during type
inference.
The issue occurred because:
1. The enum case `Nn` is desugared to a lazy val without an explicit type
2. Type inference requires typing the RHS (an anonymous class)
3. Typing the parent `Comparable[Nn.type]` requires accessing `Nn`'s type
4. This triggers `Nn`'s completer while it's already being completed
The fix detects self-references in enum case parents and provides an
explicit type annotation (the first parent, which is always the enum
type) to break the cycle. This allows the compiler to resolve `Nn.type`
without triggering recursive completion.
The explicit type is only added when there's actually a self-reference,
so normal enum cases continue to have their full type inferred as before.
0 commit comments