I noticed that if I have:
class foo(arg: Int) extends scala.annotation.StaticAnnotation
@foo(1)
@foo(2)
val x = 0
If I print the trees, the compiler shows the annotations in reverse order.
Is this considered a bug or are there no guarantees of annotation order?
This came up in ClassfileParser
.
This commit on Scala 2 says
Preserve annotation order although not meaningful.
That compromises performance as a concession to DX. It was an old question.
Scala 3 prepends on symbol.addAnnotation
(which was the previous Scala 2 behavior).
The @nowarn
annotation, which is sensitive to ordering, uses source positions for that purpose.
1 Like