Skip to content

Fixes #24414: Fix StaleSymbolException in Namer.addChild after compilation suspension#26019

Open
soronpo wants to merge 1 commit into
scala:mainfrom
soronpo:claude/fix-scala-issue-24414-nJxuw
Open

Fixes #24414: Fix StaleSymbolException in Namer.addChild after compilation suspension#26019
soronpo wants to merge 1 commit into
scala:mainfrom
soronpo:claude/fix-scala-issue-24414-nJxuw

Conversation

@soronpo
Copy link
Copy Markdown
Contributor

@soronpo soronpo commented May 8, 2026

When addChild inspects a parent's existing Child annotations, forcing their lazy tree may dereference a child symbol from a previous run. If compilation was suspended (due to inline/macro processing) and the child class has been re-typechecked in the current run, the captured symbol is stale and accessing its owner triggers StaleSymbol.

This manifests when a sealed parent is in a pre-compiled artifact and a subclass in user code uses an inline given that causes suspension: the parent's annotation list ends up holding a Child annotation pointing to the suspended-run version of the subclass.

Treat such Child annotations as stale and drop them; the new run will have re-registered the child anyway.

Fixes #24414

How much have you relied on LLM-based tools in this contribution?

Extensively, but it's a rather small fix to fix one of the dreadful State Symbol crashes.

How was the solution tested?

New automated tests (including the issue's reproducer, if applicable)

When `addChild` inspects a parent's existing Child annotations, forcing
their lazy tree may dereference a child symbol from a previous run. If
compilation was suspended (due to inline/macro processing) and the child
class has been re-typechecked in the current run, the captured symbol is
stale and accessing its owner triggers `StaleSymbol`.

This manifests when a sealed parent is in a pre-compiled artifact and a
subclass in user code uses an inline given that causes suspension: the
parent's annotation list ends up holding a Child annotation pointing to
the suspended-run version of the subclass.

Treat such Child annotations as stale and drop them; the new run will
have re-registered the child anyway.

Fixes scala#24414
@soronpo soronpo marked this pull request as ready for review May 8, 2026 22:35
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.

StaleSymbolException typechecking code with iron constraints

2 participants