Fixes #24414: Fix StaleSymbolException in Namer.addChild after compilation suspension#26019
Open
soronpo wants to merge 1 commit into
Open
Fixes #24414: Fix StaleSymbolException in Namer.addChild after compilation suspension#26019soronpo wants to merge 1 commit into
soronpo wants to merge 1 commit into
Conversation
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
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.
When
addChildinspects 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 triggersStaleSymbol.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)