Skip to content

Commit 6cbb458

Browse files
authored
Merge pull request #9262 from dotty-staging/add-multi-stage-regression-test
Add multi-stage regression test
2 parents 8c5a58f + ae4587d commit 6cbb458

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/run-staging/multi-staging.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
stage1 code: ((qctx1: scala.quoted.QuoteContext) ?=> {
2+
val x1: scala.Int = 2
3+
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)
4+
})
5+
3

tests/run-staging/multi-staging.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import scala.quoted._
3+
import scala.quoted.staging._
4+
5+
object Test {
6+
def main(args: Array[String]): Unit =
7+
val s1: QuoteContext ?=> Expr[Int] = {
8+
given Toolbox = Toolbox.make(getClass.getClassLoader)
9+
run[QuoteContext ?=> Expr[Int]] { stage1('{2}) }
10+
}
11+
{
12+
given Toolbox = Toolbox.make(getClass.getClassLoader)
13+
println(run(s1))
14+
}
15+
def stage1(x: Expr[Int])(using qctx: QuoteContext): Expr[QuoteContext ?=> Expr[Int]] =
16+
val code = '{ (using qctx1: QuoteContext) =>
17+
val x1 = $x
18+
'{ 1 + ${Expr(x1)} }
19+
}
20+
println("stage1 code: " + code.show)
21+
code
22+
23+
}

0 commit comments

Comments
 (0)