所以我在函数上有一个注释(DefDef).此注释具有参数.但是,我对如何从构造函数中获取参数感到困惑.
用法示例:
class TestMacro {
@Foo(true)
def foo(): String = ""
foo
}
Run Code Online (Sandbox Code Playgroud)
这是注释的代码:
class Foo(b: Boolean) extends StaticAnnotation {
def macroTransform(annottees: Any*) = macro Foo.impl
}
object Foo {
def impl(c: whitebox.Context)(annottees: c.Tree*): c.Expr[Any] = {
import c.universe._
//how do I get value of `b` here???
c.abort(c.enclosingPosition, "message")
}
}
Run Code Online (Sandbox Code Playgroud)