I'm use Scalameta(v1.8.0) annotation to a def declaration:
trait MyTrait {
@MyDeclDef
def f2(): Int
}
The annotation class defined just return input, as this:
import scala.meta._
class MyDeclDef extends scala.annotation.StaticAnnotation {
inline def apply(defn: Any): Any = meta {
defn match {
case defn: Decl.Def =>
defn
case _ =>
println(defn.structure)
abort("@MyDeclDef most annotate a Decl.Def")
}
}
}
some compiler error encounter:
Error:'=' expected but eof found.
def f2(): Unit
Error:illegal start of simple expression
def f2(): Unit
Besides, If I use Decl.Var
to var v2: Int
it works fine.
How to right annotate a trait def
? Thanks