Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prevent accidentally dropping annotations#11173

Merged
lrytz merged 1 commit into
scala:2.13.xfrom
lrytz:t13140
Nov 4, 2025
Merged

Prevent accidentally dropping annotations#11173
lrytz merged 1 commit into
scala:2.13.xfrom
lrytz:t13140

Conversation

@lrytz
Copy link
Copy Markdown
Member

@lrytz lrytz commented Oct 31, 2025

Explicitly define "target meta annotations" in the compiler.

When target annotations @(deprecated @getter) were introduced, all annotations in the package annotation.meta were target annotations.

In the meantime there are others, which broke annotation filtering.

    def mkFilter(category: Symbol, defaultRetention: Boolean)(ann: AnnotationInfo) =
      (ann.targetAnnotations, ann.defaultTargets) match {
        case (Nil, Nil)      => defaultRetention
        case (Nil, defaults) => defaults contains category
        case (metas, _)      => metas exists (_ matches category)
      }

we ended up in the second case with defaults being the superArg meta annotation, which is not a target annotation.

Fixes scala/bug#13140

@scala-jenkins scala-jenkins added this to the 2.13.18 milestone Oct 31, 2025
@SethTisue SethTisue added prio:hi high priority (used only by core team, only near release time) release-notes worth highlighting in next release notes labels Nov 2, 2025
@lrytz lrytz requested a review from som-snytt November 3, 2025 09:11
Copy link
Copy Markdown
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

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

I never met a Anne O'Tayshun I didn't like.

Comment thread src/reflect/scala/reflect/internal/AnnotationInfos.scala
When target annotations `@(deprecated @Getter)` were introduced, all
annotations in the package `annotation.meta` were target annotations.

In the meantime there are others, which broke annotation filtering.

```
    def mkFilter(category: Symbol, defaultRetention: Boolean)(ann: AnnotationInfo) =
      (ann.targetAnnotations, ann.defaultTargets) match {
        case (Nil, Nil)      => defaultRetention
        case (Nil, defaults) => defaults contains category
        case (metas, _)      => metas exists (_ matches category)
      }
```

we ended up in the second case with `defaults` being the `superArg` meta
annotation, which is not a target annotation.
@lrytz lrytz merged commit edff6af into scala:2.13.x Nov 4, 2025
3 checks passed
@lrytz lrytz removed the prio:hi high priority (used only by core team, only near release time) label Nov 4, 2025
@lrytz lrytz changed the title Explicitly define "target meta annotations" in the compiler Prevent accidentally dropping annotations Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes worth highlighting in next release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some annotations are not visible in macros since 2.13.17

4 participants