Skip to content

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
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
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
3 participants