So, lets say I have a few things before hand:
case class M[A](val value: A) {
def apply(as: M[A]*) = macro applyImpl[A]
}
def tpAware(implicit ev: Context[A]): M[A]
val ma: M[X] = ???
I want to do:
ma(tpAware)
Where applyImpl
is defined something like
def applyVG[A : c.WeakTypeTag, V](c: MacroContext)(vs: c.Expr[M[V]]*): c.Expr[M[A]] = {
import c.universe._
val container = c.prefix.tree.collect {
case a@Apply(n, xs) => xs
}.flatten.apply(1)
val expr = reify {
M {
implicit val ev = Context[A]()
val container = c.Expr[A](container).splice
sequence(c)(vs).splice foreach { c =>
container.add(c.value)
}
container
}
}
expr
}
The problem now, is that the typer runs before the macro is expanded, and my Context[A]
is not visible prior to the application of apply
Wat do?