Skip to content

Add multi-stage regression test #9262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/run-staging/multi-staging.check
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions tests/run-staging/multi-staging.scala
Original file line number Diff line number Diff line change
@@ -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

}