Skip to content

Avoid crashing for an inlined Java annot with a default value - #27095

Merged
tanishiking merged 1 commit into
scala:mainfrom
dotty-staging:solal/java-annot-default
Sep 25, 2026
Merged

tanishiking merged 1 commit into
scala:mainfrom
dotty-staging:solal/java-annot-default

Conversation

@SolalPirelli

Copy link
Copy Markdown
Contributor

Fixes #27078

I don't like this. But what else can we do?

Have you relied on LLM-based tools in this contribution?

No

How was the solution tested?

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

@SolalPirelli
SolalPirelli marked this pull request as ready for review September 18, 2026 06:53

@tanishiking tanishiking left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this avoids the compiler crash, I'm not sure filling null instead of the default value is an expected behavior.
On top of that, in this case we are putting null where a primitive value is expected (unfilledDefault2), so it fails at runtime with Caused by: java.lang.VerifyError: Bad type on operand stack.

TBH, I'm not yet sure I am not yet sure what should we do / should this work in the first place 🤔

@SolalPirelli
SolalPirelli force-pushed the solal/java-annot-default branch from 34cbaef to bff5ac7 Compare September 23, 2026 13:39
@SolalPirelli

Copy link
Copy Markdown
Contributor Author

@tanishiking you're right, thanks... I discussed this with Seb offline and he suggested that anything a macro creates that you couldn't write yourself isn't supported. So I changed this PR to report an error instead.

@som-snytt som-snytt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same question about ersatz trees. It may be fine in backend, but normally it's errorTree for a tree with ErrorType. (As opposed to EmptyTree as a placeholder.) I just wonder about interactions with unsuspecting plugins or whatever. Reporting an error may not stop the world?

@SolalPirelli

Copy link
Copy Markdown
Contributor Author

I just wonder about interactions with unsuspecting plugins or whatever. Reporting an error may not stop the world?

Good question, I don't think we have a general way to deal with this anyway. If someone has a plugin affected by this we can figure it out.

@tanishiking tanishiking left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Yeah, emit error makes more sense 👍

@tanishiking
tanishiking merged commit 3577f77 into scala:main Sep 25, 2026
64 checks passed
@tanishiking
tanishiking deleted the solal/java-annot-default branch September 25, 2026 03:52
@WojciechMazur WojciechMazur added this to the 3.10.1 milestone Oct 11, 2026
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.

Inlined Java annotation with default value crashes backend

4 participants