Closed rssh closed 4 years ago
Minimized to
import scala.quoted._
object Test
def run(given qctx: QuoteContext)(tree: qctx.tasty.Tree): Unit =
'{ ${(given qctx2) => makeExpr(given qctx2)(tree) } + 1 }
def makeExpr(given qctx: QuoteContext)(tree: qctx.tasty.Tree): Expr[Int] = ???
The issue is that currently there is no relation between the context given to the quote and the one provided by the splice.
Workarounds
import scala.quoted._
object Test
def run(given qctx: QuoteContext)(tree: qctx.tasty.Tree): Unit =
val expr = makeExpr(tree)
'{ $expr + 1 }
def makeExpr(given qctx: QuoteContext)(tree: qctx.tasty.Tree): Expr[Int] = ???
import scala.quoted._
object Test
def run(given qctx: QuoteContext)(tree: qctx.tasty.Tree): Unit =
'{ ${(given qctx2: QuoteContext) => makeExpr(given qctx)(tree) } + 1 }
def makeExpr(given qctx: QuoteContext)(tree: qctx.tasty.Tree): Expr[Int] = ???
minimized code
expectation
should compiled.