diff --git a/tests/run-staging/i8178.scala b/tests/run-staging/i8178.scala new file mode 100644 index 000000000000..300a06c588fd --- /dev/null +++ b/tests/run-staging/i8178.scala @@ -0,0 +1,15 @@ +import scala.quoted._ +import scala.quoted.staging._ + +def foo(n: Int, t: Expr[Int])(using QuoteContext): Expr[Int] = + if (n == 0) t + else '{ val a = ${Expr(n)}; ${foo(n - 1, 'a)} + $t } + +@main def Test = { + // make available the necessary toolbox for runtime code generation + given Toolbox = Toolbox.make(getClass.getClassLoader) + + val f: Int = run { foo(2, Expr(5)) } + + println(f) +}