I copied this here from https://github.com/lampepfl/dotty/issues/10446 since it is SIP material.
The question is what kind of effects we want an annotation to have. I did a survey of existing Scala annotations to find out. There emerge two broad categories:
-
tighten or relax error checking or warnings, or customize error messages
-
Scala 2
@compiletimeOnly @implicitAmbiguous @implicitNotFound @nowarn @showAsInfix @switch @tailrec @unused @uncheckedStable @uncheckedVariance @deprecated... @unchecked
-
Scala 3 additions
@constructorOnly
-
-
influence code generation and run-time behavior
-
Scala 2
@elidable @strictfp @specialized @unspecialized @varargs @inline @noinline @native @throws @transient @volatile
-
Scala 3 additions
@main @static @targetName @threadUnsafe
-
There are only two annotatiions that do not fit into this categorization.
I believe it is a good idea to have clear guidelines what annotations can and cannot do, and to keep to these guidelines in our own distribution. Otherwise we’ll risk a “broken window” effect where soon enough annotations are free to change or influence anything so that no categorization is possible anymore. This will be particularly important to set expectations what an eventual annotation macro design should accomplish.
With that in mind there’s a good case to be made to make infix
and mixin
soft modifiers instead. I can’t really see a downside to doing this. But we have to do it quickly, before we release Scala 3.