Say I have a macro annotation AnnProxy and the following code:
trait MyTrait
{
def x: Int
}
@AnnProxy
class MyClass extends MyTrait
I now need to get the Type of MyTrait so that I can proxy it's methods. So far my code looks like:
@compileTimeOnly("enable macro paradise to expand macro annotations")
class AnnProxy extends StaticAnnotation
{
def macroTransform(annottees: Any*): Any = macro IdentityMacro.impl
}
object IdentityMacro
{
def impl(c: whitebox.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
import c.universe._
val inputs = annottees.map(_.tree).toList
val classDef = inputs.head.asInstanceOf[ClassDef]
val superclass= // how do I get the Type of the superclass?
c.Expr[Any] {
q"""
class ${classDef.name} {
def doit() : Unit = println("doit")
}
"""
}
}
}