Skip to content

Fix compiler crash when splicing annotations with lambdas read from TASTy - #5702

Merged
adamw merged 2 commits into
masterfrom
fix-annotation-lambda-splice
Nov 26, 2026
Merged

adamw merged 2 commits into
masterfrom
fix-annotation-lambda-splice

Conversation

@adamw

@adamw adamw commented Nov 26, 2026

Copy link
Copy Markdown
Member

Compiling a type that has an annotation with a lambda (e.g. @customise(_.format("x"))) could crash with scala.MatchError: 23 in TreeUnpickler.readConstant. This happens when the annotated type is read from TASTy (another module, or an incremental compile) and the macro splices the annotation more than once. It broke the release build when only SchemaMacroTest was recompiled.

This is a Scala 3 compiler bug (still present in 3.10.2-RC1): the lambda body is read lazily, and a second read starts at the wrong position. The fix reads the annotation trees fully once, before splicing them.

Magnolia's annotation handling has the same problem, so Schema.derived can still crash for such types. That needs a compiler fix.

🤖 Generated with Claude Code

@adamw
adamw merged commit 4507102 into master Nov 26, 2026
27 checks passed
@adamw
adamw deleted the fix-annotation-lambda-splice branch November 26, 2026 08:24
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.

1 participant