From ae4587d15ba052d266ab57d0b0f2989ff96ca7dc Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 30 Jun 2020 11:32:09 +0200 Subject: [PATCH] Add multi-stage regression test --- tests/run-staging/multi-staging.check | 5 +++++ tests/run-staging/multi-staging.scala | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/run-staging/multi-staging.check create mode 100644 tests/run-staging/multi-staging.scala diff --git a/tests/run-staging/multi-staging.check b/tests/run-staging/multi-staging.check new file mode 100644 index 000000000000..54bfae0617ff --- /dev/null +++ b/tests/run-staging/multi-staging.check @@ -0,0 +1,5 @@ +stage1 code: ((qctx1: scala.quoted.QuoteContext) ?=> { + val x1: scala.Int = 2 + scala.internal.quoted.CompileTime.exprQuote[scala.Int](1.+(scala.internal.quoted.CompileTime.exprNestedSplice[scala.Int](qctx1)(((evidence$5: qctx1.Nested) ?=> scala.quoted.Expr.apply[scala.Int](x1)(evidence$5, scala.quoted.Liftable.IntIsLiftable[scala.Int]))))).apply(using qctx1) +}) +3 diff --git a/tests/run-staging/multi-staging.scala b/tests/run-staging/multi-staging.scala new file mode 100644 index 000000000000..78bd3e8ffd96 --- /dev/null +++ b/tests/run-staging/multi-staging.scala @@ -0,0 +1,23 @@ + +import scala.quoted._ +import scala.quoted.staging._ + +object Test { + def main(args: Array[String]): Unit = + val s1: QuoteContext ?=> Expr[Int] = { + given Toolbox = Toolbox.make(getClass.getClassLoader) + run[QuoteContext ?=> Expr[Int]] { stage1('{2}) } + } + { + given Toolbox = Toolbox.make(getClass.getClassLoader) + println(run(s1)) + } + def stage1(x: Expr[Int])(using qctx: QuoteContext): Expr[QuoteContext ?=> Expr[Int]] = + val code = '{ (using qctx1: QuoteContext) => + val x1 = $x + '{ 1 + ${Expr(x1)} } + } + println("stage1 code: " + code.show) + code + +}