I am working with macro annotations (link) that are part of the macro paradise of Scala.
In their example they use a macro annotation called identity
which takes no parameters. However, the macro annotation I am trying to implement does require an argument:
@compileTimeOnly("enable macro paradise to expand macro annotations")
class f(id: String) extends StaticAnnotation {
def macroTransform(annottees: Any*) = macro identityMacro.impl
}
object identityMacro extends App {
def impl(c: Context)(annottees: c.Expr[Any]*) = {
import c.universe._
// how to access id here?
}
}
My question: how can I access the value of id
in the implementation of the identityMacro.impl
macro? I have tried passing it as an extra argument to macroTransform
but this does not work. I assume I have to access it via the Context?