I'm trying to write a generic macro in which I can grab any trees that match foo.bar
, but only where foo
is a Foo
. I only need to look inside the enclosing class where the macro is called. So far I have this:
def getFooTrees[T](): Unit = macro getFooTrees_impl[T]
def getFooTrees_impl[T: c.WeakTypeTag](c: Context)(): c.Expr[Unit] = {
import c.universe._
val receiverType = implicitly[c.WeakTypeTag[T]].tpe
val terms = c.enclosingClass
.filter { t =>
t match {
case Select(ident: Ident, name: TermName) if (??? == receiverType) =>
true
case _ =>
false
}
}
...etc
}
How do I check the type of what ident
refers to? Sorry if I'm totally lost in the woods here.