From c313fd73a7f49b69f7eb1b26c1c30a4babddbfb1 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 4 Feb 2020 08:07:54 +0100 Subject: [PATCH] Fix #8178: add test Cannot reproduce on master --- tests/run-staging/i8178.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/run-staging/i8178.scala 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) +}