Skip to content

Conversation

@ecrabor8
Copy link

@ecrabor8 ecrabor8 commented Jan 4, 2026

This PR fixes issue #22991 by retaining parameter annotations in mixin phase
generation of forwarder methods.
Therefore, a trait method parameter annotated with Java RetentionPolicy.RUNTIME
annotation is retained in the subclasses .class file in same named method/parameter
for Java reflection use.
This restores the behavior of Scala 2 for such RUNTIME annotated paramters.

Closes ticket #22991

Note -- This is one of two PR choices that fix the issue. Consider this one as first cut with simplest set of changes.

Fixes #22991

…ding methods

    This PR fixes issue scala#22991 by retaining parameter annotations in mixin phase
    generation of forwarder methods.
    Therefore, a trait method parameter annotated with Java RetentionPolicy.RUNTIME
    annotation is retained in the subclasses .class file in same named method/parameter
    for Java reflection use.
    This restores the behavior of Scala 2 for such RUNTIME annotated paramters.

    Closes ticket scala#22991
*/
def DefDef(sym: TermSymbol, rhsFn: List[List[Tree]] => Tree)(using Context): DefDef =

def DefDef(sym: TermSymbol, annotationsFn: (TermName => List[Annotation]) | Null, rhsFn: List[List[Tree]] => Tree)(using Context): DefDef =
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid null at an (internal) API boundary.

@odersky odersky removed their assignment Jan 16, 2026
@odersky
Copy link
Contributor

odersky commented Jan 16, 2026

I don't think I am the best person to review this. See my comment on the other PR.

@som-snytt
Copy link
Contributor

@ecrabor8 you presumably agree that this is superseded by #24916

@som-snytt som-snytt closed this Jan 16, 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.

Trait method parameter annotated with RetentionPolicy.RUNTIME annotation is not indicated in .class file for the method parameter

3 participants