由于某种原因,每次我尝试调用带有准引号的隐式参数的函数时,它都会失败Can't unquote x.universe.Tree, consider providing an implicit instance of Liftable[x.universe.Tree]
那有什么不对吗?我不能这么做吗?我找不到任何地方说我不能做
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
object Foo {
def foo: Unit = macro fooImpl
def fooImpl(c: whitebox.Context): c.Expr[Unit] = {
import c.universe._
implicit val x = c
val res = q"$sysoutFQN"
c.Expr(res)
}
def sysoutFQN(implicit c: whitebox.Context): c.universe.Tree = {
import c.universe._
q"java.lang.System.out.println()"
}
}
因为路径依赖所以c.universe.Tree != x.universe.Tree
implicit val x: c.type = c