出于某种原因,每次我尝试使用准引号中的隐式参数调用函数时,它都会失败
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()"
}
}