【发布时间】:2015-07-18 20:43:36
【问题描述】:
我有以下代码:
@compileTimeOnly("enable macro paradise to expand macro annotations")
class typedTable[T] extends StaticAnnotation {
def macroTransform(annottees: Any*): Table = macro TableGenerator.impl[T]
}
object TableGenerator {
def impl[T](c: whitebox.Context)(annottees: c.Expr[Any]*): c.Expr[Table] = {
import c.universe._
val tpe = weakTypeOf[T] // This doesn't work
...
}
}
而且我似乎无法弄清楚如何在宏注释中访问“T”的 TypeTag。我看到其他帖子模糊地提到了如何访问它,但我似乎无法弄清楚在这种情况下我应该如何访问它。
【问题讨论】:
标签: scala generics macros annotations