Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copy of annotation on @main methods #22582

Merged
merged 1 commit into from
Feb 12, 2025
Merged

Fix copy of annotation on @main methods #22582

merged 1 commit into from
Feb 12, 2025

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Feb 11, 2025

Fixes #22364.

See #13858 (comment).

val annots = mainFun.annotations
.filterNot(_.matches(defn.MainAnnot))
.map(annot => insertTypeSplices.transform(annot.tree))
.map(annot => TypedSplice(annot.tree)(using annotsCtx))
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, here the annotations are copied from the top-level method (mainFun) to the synthetic main method. Does the AST not need to be duplicated? Or does changeOwner in typedTypedSplice duplicate it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or does changeOwner in typedTypedSplice duplicate it?

Yes, the TypeTreeMap in changeOwner will copy the subtrees that differ. I think that should be enough?

@mbovel mbovel merged commit a61c12e into scala:main Feb 12, 2025
29 checks passed
@mbovel mbovel deleted the mb/22364 branch February 12, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler crash with annotation on main method
2 participants