-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for repeatable annotations #10751
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
Conversation
refs: scala/scala#6846 |
@sjrd, will you be able to review this? |
Hum, probably not. I didn't notice I had been assigned, and I'm not sure why either: it's not at all my area of expertise. |
@liufengyun would you be available to review this? |
Yes, I can have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, LGTM 👍
compiler/src/dotty/tools/dotc/transform/RepeatableAnnotations.scala
Outdated
Show resolved
Hide resolved
compiler/src/dotty/tools/dotc/transform/RepeatableAnnotations.scala
Outdated
Show resolved
Hide resolved
compiler/src/dotty/tools/dotc/transform/RepeatableAnnotations.scala
Outdated
Show resolved
Hide resolved
compiler/src/dotty/tools/dotc/transform/RepeatableAnnotations.scala
Outdated
Show resolved
Hide resolved
private def transformDef(tree: DefTree)(using Context) = | ||
val annotations = tree.symbol.annotations | ||
if (!annotations.isEmpty) then | ||
tree.symbol.annotations = aggregateAnnotations(tree.symbol.annotations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, we use SymTransformer
to change symbol denotations. I think here it's fine to do so as the change is not supposed to be visible in a separately compiled module.
- now only the first clashing annotation is reported Co-authored-by: Fengyun Liu <[email protected]>
Fixes #5092
Before this PR, using multiple annotations of the same type on any symbol would generate incorrect bytecode; this can lead to runtime exceptions when reflection is used.
This PR makes the compiler check if they are multiple annotations of the same type and raise a compile error or aggregate them if their type supports it.