Skip to content

Fixes #24719 Fix LazyAnnotation.tree reentrance in Namer.addChild#25909

Open
soronpo wants to merge 2 commits intoscala:mainfrom
soronpo:claude/fix-scala3-24719-ZLFtH
Open

Fixes #24719 Fix LazyAnnotation.tree reentrance in Namer.addChild#25909
soronpo wants to merge 2 commits intoscala:mainfrom
soronpo:claude/fix-scala3-24719-ZLFtH

Conversation

@soronpo
Copy link
Copy Markdown
Contributor

@soronpo soronpo commented Apr 22, 2026

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 #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)

claude added 2 commits April 22, 2026 17:39
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
@soronpo soronpo marked this pull request as ready for review April 22, 2026 19:04
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.

Assertion failure in LazyAnnotation.tree

2 participants