scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Multiple @nowarn annotations not supported on 2.12 #12898

Closed lrytz closed 5 months ago

lrytz commented 7 months ago

This works on 2.13

@annotation.nowarn("msg=Auto") @annotation.nowarn("msg=procedure") def f { println }

but 2.12 gives

<console>:11: error: class nowarn may not appear multiple times on method f
       @annotation.nowarn("msg=Auto") @annotation.nowarn("msg=procedure") def f { println }

because on 2.12 nowarn extends ClassfileAnnotation to ensure the argument is a constant. This triggers

https://github.com/scala/scala/blob/v2.12.18/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L1481