假设我想复制一个像 @specialized(Int) 这样的注解——我知道这很疯狂——使用宏注解。就像是:
class expand(expanded: Any*) extends Annotation with StaticAnnotation {
def macroTransform(annottees: Any*) = macro expand.expandImpl
}
object expand {
def expandImpl(c: Context)(annottees: c.Expr[Any]*):c.Expr[Any] = {
// would like to be able to get access to the "expanded" args above.
???
}
}
// Usage:
def foo[@expand(Int) T] = 4
有什么方法可以访问注释的参数(示例中为 Int)?