Fixes #24719 Fix LazyAnnotation.tree reentrance in Namer.addChild#25909
Open
soronpo wants to merge 2 commits intoscala:mainfrom
Open
Fixes #24719 Fix LazyAnnotation.tree reentrance in Namer.addChild#25909soronpo wants to merge 2 commits intoscala:mainfrom
soronpo wants to merge 2 commits intoscala:mainfrom
Conversation
When `addChild` inspects an existing Child annotation via `Annotation.Child.unapply`, it forces the annotation's lazy tree. If that forcing triggers completion of another class that also needs to be added as a child of the same parent, we re-enter `addChild` and hit the same Child annotation while it is still being evaluated, which trips the `assert(myTree != null)` in `LazyAnnotation.tree`. This happens for example when user code defines `scala.Tuple1` and `scala.Tuple22` in the `scala` package: `adjustForTuple` makes them extend the sealed `scala.*:`, whose pickled Child annotations resolve back to the user-defined classes, causing recursive completion. Skip Child annotations that are currently being forced so the iteration falls back to prepending the new annotation instead of crashing. Fixes scala#24719
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 an existing Child annotation viaAnnotation.Child.unapply, it forces the annotation's lazy tree. If that forcing triggers completion of another class that also needs to be added as a child of the same parent, we re-enteraddChildand hit the same Child annotation while it is still being evaluated, which trips theassert(myTree != null)inLazyAnnotation.tree.This happens for example when user code defines
scala.Tuple1andscala.Tuple22in thescalapackage:adjustForTuplemakes them extend the sealedscala.*:, whose pickled Child annotations resolve back to the user-defined classes, causing recursive completion.Skip Child annotations that are currently being forced so the iteration falls back to prepending the new annotation instead of crashing.
Fixes #24719
How much have you relied on LLM-based tools in this contribution?
Extensively, but this is a very small change.
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)