From 9e3fdb9f41c779f88c5b394b7591341b6681402e Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sat, 15 Jun 2019 12:12:33 +0200 Subject: [PATCH] Homogenize $ and run notation Now both `$` and `run` correspond to ```scala def $[T](expr: Expr[T]): T = ... def run[T](expr: Expr[T]): T = ... ``` This is the first step towards correct context handling in quote and splices. --- compiler/test-resources/repl-macros/i6007 | 2 +- library/src-2.x/scala/quoted/Expr.scala | 1 + library/src-3.x/scala/quoted/Expr.scala | 1 + library/src-3.x/scala/quoted/package.scala | 14 ++++++++++ .../staged-streams_1.scala | 20 +++++++------- tests/run-with-compiler/i3876-b.scala | 2 +- tests/run-with-compiler/i3876-c.scala | 2 +- tests/run-with-compiler/i3876-d.scala | 2 +- tests/run-with-compiler/i3876-e.scala | 2 +- tests/run-with-compiler/i3876.scala | 2 +- tests/run-with-compiler/i3946.scala | 2 +- tests/run-with-compiler/i3947.scala | 2 +- tests/run-with-compiler/i3947b.scala | 2 +- tests/run-with-compiler/i3947b2.scala | 2 +- tests/run-with-compiler/i3947b3.scala | 2 +- tests/run-with-compiler/i3947c.scala | 2 +- tests/run-with-compiler/i3947d.scala | 2 +- tests/run-with-compiler/i3947d2.scala | 2 +- tests/run-with-compiler/i3947e.scala | 2 +- tests/run-with-compiler/i3947f.scala | 2 +- tests/run-with-compiler/i3947g.scala | 2 +- tests/run-with-compiler/i3947i.scala | 2 +- tests/run-with-compiler/i3947j.scala | 2 +- tests/run-with-compiler/i4591.scala | 2 +- tests/run-with-compiler/i5965.scala | 6 ++--- tests/run-with-compiler/i5965b.scala | 6 ++--- .../run-with-compiler/quote-ackermann-1.scala | 2 +- tests/run-with-compiler/quote-fun-app-1.scala | 4 ++- tests/run-with-compiler/quote-owners-2.scala | 2 +- tests/run-with-compiler/quote-owners.scala | 2 +- tests/run-with-compiler/quote-run-b.scala | 2 +- tests/run-with-compiler/quote-run-c.scala | 8 +++--- .../quote-run-constants.scala | 26 +++++++++--------- tests/run-with-compiler/quote-run-many.scala | 4 ++- .../quote-run-staged-interpreter.scala | 12 ++++++--- .../quote-run-with-settings.scala | 4 +-- tests/run-with-compiler/quote-run.scala | 4 +-- tests/run-with-compiler/quote-var.scala | 5 +++- .../run-with-compiler/shonan-hmm-simple.scala | 10 +++---- .../staged-tuples/Test.scala | 27 ++++++++++--------- .../quoted_1.scala | 12 ++++++--- 41 files changed, 124 insertions(+), 88 deletions(-) diff --git a/compiler/test-resources/repl-macros/i6007 b/compiler/test-resources/repl-macros/i6007 index cea674769f88..4f3d9dfafa1f 100644 --- a/compiler/test-resources/repl-macros/i6007 +++ b/compiler/test-resources/repl-macros/i6007 @@ -4,5 +4,5 @@ scala> val v = '{ (if true then Some(1) else None).map(v => v+1) } val v: quoted.Expr[Option[Int]] = Expr() scala> v.show val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1))) -scala> v.run +scala> scala.quoted.run(v) val res1: Option[Int] = Some(2) diff --git a/library/src-2.x/scala/quoted/Expr.scala b/library/src-2.x/scala/quoted/Expr.scala index d7ba425b9cc5..ae026993939b 100644 --- a/library/src-2.x/scala/quoted/Expr.scala +++ b/library/src-2.x/scala/quoted/Expr.scala @@ -8,6 +8,7 @@ package quoted { * * May throw a FreeVariableError on expressions that came from a macro. */ + @deprecated("Use scala.quoted.run", "") final def run(implicit toolbox: Toolbox): T = toolbox.run(this) } diff --git a/library/src-3.x/scala/quoted/Expr.scala b/library/src-3.x/scala/quoted/Expr.scala index 2300346c8b7b..9d4b5046407f 100644 --- a/library/src-3.x/scala/quoted/Expr.scala +++ b/library/src-3.x/scala/quoted/Expr.scala @@ -8,6 +8,7 @@ package quoted { * * May throw a FreeVariableError on expressions that came from a macro. */ + @deprecated("Use scala.quoted.run", "") final def run(implicit toolbox: Toolbox): T = toolbox.run(this) } diff --git a/library/src-3.x/scala/quoted/package.scala b/library/src-3.x/scala/quoted/package.scala index b81b5350d11a..abfc93786018 100644 --- a/library/src-3.x/scala/quoted/package.scala +++ b/library/src-3.x/scala/quoted/package.scala @@ -2,6 +2,20 @@ package scala package object quoted { + /** Evaluate the contents of this expression and return the result. + * + * Usage: + * ``` + * val e: T = run { + * expr + * } + * ``` + * where `expr: Expr[T]` + * + * May throw a FreeVariableError on expressions that came from a macro. + */ + def run[T](expr: Expr[T]) given (toolbox: Toolbox): T = toolbox.run(expr) + object autolift { implicit def autoToExpr[T: Liftable](x: T): Expr[T] = x.toExpr } diff --git a/tests/run-with-compiler-custom-args/staged-streams_1.scala b/tests/run-with-compiler-custom-args/staged-streams_1.scala index 5e0ebc8c4931..1a6a716f8b31 100644 --- a/tests/run-with-compiler-custom-args/staged-streams_1.scala +++ b/tests/run-with-compiler-custom-args/staged-streams_1.scala @@ -678,25 +678,25 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - println(test1().run) + println(run(test1())) println - println(test2().run) + println(run(test2())) println - println(test3().run) + println(run(test3())) println - println(test4().run) + println(run(test4())) println - println(test5().run) + println(run(test5())) println - println(test6().run) + println(run(test6())) println - println(test7().run) + println(run(test7())) println - println(test8().run) + println(run(test8())) println - println(test9().run) + println(run(test9())) println - println(test10().run) + println(run(test10())) } } diff --git a/tests/run-with-compiler/i3876-b.scala b/tests/run-with-compiler/i3876-b.scala index b4eda5c9c3a4..ba854e80eee6 100644 --- a/tests/run-with-compiler/i3876-b.scala +++ b/tests/run-with-compiler/i3876-b.scala @@ -9,7 +9,7 @@ object Test { def f(x: Int): Int = x + x f } - println(f2(x).run) + println(run(f2(x))) println(f2(x).show) } } diff --git a/tests/run-with-compiler/i3876-c.scala b/tests/run-with-compiler/i3876-c.scala index 1f8cef379856..aad2bfd063e8 100644 --- a/tests/run-with-compiler/i3876-c.scala +++ b/tests/run-with-compiler/i3876-c.scala @@ -9,7 +9,7 @@ object Test { val f: (x: Int) => Int = x => x + x f } - println(f3(x).run) + println(run(f3(x))) println(f3(x).show) // TODO improve printer } } diff --git a/tests/run-with-compiler/i3876-d.scala b/tests/run-with-compiler/i3876-d.scala index 24075b701f3f..a64dd09213bc 100644 --- a/tests/run-with-compiler/i3876-d.scala +++ b/tests/run-with-compiler/i3876-d.scala @@ -8,7 +8,7 @@ object Test { val f4: Expr[Int => Int] = '{ inlineLambda } - println(f4(x).run) + println(run(f4(x))) println(f4(x).show) } diff --git a/tests/run-with-compiler/i3876-e.scala b/tests/run-with-compiler/i3876-e.scala index 143b2d817963..a6cb5ab158d5 100644 --- a/tests/run-with-compiler/i3876-e.scala +++ b/tests/run-with-compiler/i3876-e.scala @@ -8,7 +8,7 @@ object Test { val f4: Expr[Int => Int] = '{ inlineLambda } - println(f4(x).run) + println(run(f4(x))) println(f4(x).show) } diff --git a/tests/run-with-compiler/i3876.scala b/tests/run-with-compiler/i3876.scala index 418bdee7d3f2..0b76e6c534c3 100644 --- a/tests/run-with-compiler/i3876.scala +++ b/tests/run-with-compiler/i3876.scala @@ -6,7 +6,7 @@ object Test { val x: Expr[Int] = '{3} val f: Expr[Int => Int] = '{ (x: Int) => x + x } - println(f(x).run) + println(run(f(x))) println(f(x).show) } } diff --git a/tests/run-with-compiler/i3946.scala b/tests/run-with-compiler/i3946.scala index 84c31b7b6789..73aece729e0b 100644 --- a/tests/run-with-compiler/i3946.scala +++ b/tests/run-with-compiler/i3946.scala @@ -4,6 +4,6 @@ object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) val u: Expr[Unit] = '{} println(u.show) - println(u.run) + println(run(u)) } } diff --git a/tests/run-with-compiler/i3947.scala b/tests/run-with-compiler/i3947.scala index 5ec35a804fe1..d6fb9b9c81c1 100644 --- a/tests/run-with-compiler/i3947.scala +++ b/tests/run-with-compiler/i3947.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // classOf[Object] diff --git a/tests/run-with-compiler/i3947b.scala b/tests/run-with-compiler/i3947b.scala index b623b8f9fc16..f27cd8c04d64 100644 --- a/tests/run-with-compiler/i3947b.scala +++ b/tests/run-with-compiler/i3947b.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // primitives diff --git a/tests/run-with-compiler/i3947b2.scala b/tests/run-with-compiler/i3947b2.scala index b10a46d97301..5956b3da4df7 100644 --- a/tests/run-with-compiler/i3947b2.scala +++ b/tests/run-with-compiler/i3947b2.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // primitives diff --git a/tests/run-with-compiler/i3947b3.scala b/tests/run-with-compiler/i3947b3.scala index 15d33d9ae4d2..cc5bfd616d48 100644 --- a/tests/run-with-compiler/i3947b3.scala +++ b/tests/run-with-compiler/i3947b3.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // primitives diff --git a/tests/run-with-compiler/i3947c.scala b/tests/run-with-compiler/i3947c.scala index 1642692145bf..ffd458237a05 100644 --- a/tests/run-with-compiler/i3947c.scala +++ b/tests/run-with-compiler/i3947c.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } test(classOf[Null]) diff --git a/tests/run-with-compiler/i3947d.scala b/tests/run-with-compiler/i3947d.scala index 11baf2773417..78da0408257e 100644 --- a/tests/run-with-compiler/i3947d.scala +++ b/tests/run-with-compiler/i3947d.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } test(classOf[Foo]) diff --git a/tests/run-with-compiler/i3947d2.scala b/tests/run-with-compiler/i3947d2.scala index 2969ded0e436..38852e71fbfd 100644 --- a/tests/run-with-compiler/i3947d2.scala +++ b/tests/run-with-compiler/i3947d2.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } test(classOf[foo.Foo]) diff --git a/tests/run-with-compiler/i3947e.scala b/tests/run-with-compiler/i3947e.scala index b0d0706cca30..39b6f54c2e3a 100644 --- a/tests/run-with-compiler/i3947e.scala +++ b/tests/run-with-compiler/i3947e.scala @@ -11,7 +11,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // class Object diff --git a/tests/run-with-compiler/i3947f.scala b/tests/run-with-compiler/i3947f.scala index d74159272676..68b4c562f01c 100644 --- a/tests/run-with-compiler/i3947f.scala +++ b/tests/run-with-compiler/i3947f.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // class Array[Object] diff --git a/tests/run-with-compiler/i3947g.scala b/tests/run-with-compiler/i3947g.scala index 6d9e1ec0524c..59343ddf9035 100644 --- a/tests/run-with-compiler/i3947g.scala +++ b/tests/run-with-compiler/i3947g.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // primitive arrays diff --git a/tests/run-with-compiler/i3947i.scala b/tests/run-with-compiler/i3947i.scala index 6f3241ae6be0..9739e27d207e 100644 --- a/tests/run-with-compiler/i3947i.scala +++ b/tests/run-with-compiler/i3947i.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } // primitive arrays diff --git a/tests/run-with-compiler/i3947j.scala b/tests/run-with-compiler/i3947j.scala index 2d14db5bf052..c8f2b121f174 100644 --- a/tests/run-with-compiler/i3947j.scala +++ b/tests/run-with-compiler/i3947j.scala @@ -10,7 +10,7 @@ object Test { val name = '{ ($lclazz).getCanonicalName } println() println(name.show) - println(name.run) + println(run(name)) } test(classOf[Array[Array[Int]]]) diff --git a/tests/run-with-compiler/i4591.scala b/tests/run-with-compiler/i4591.scala index c862e316c96f..d75d45815b0e 100644 --- a/tests/run-with-compiler/i4591.scala +++ b/tests/run-with-compiler/i4591.scala @@ -9,7 +9,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - foo('{Option(9)}).run + run(foo('{Option(9)})) } } diff --git a/tests/run-with-compiler/i5965.scala b/tests/run-with-compiler/i5965.scala index f1bbb3c6ab05..58fa88f15e88 100644 --- a/tests/run-with-compiler/i5965.scala +++ b/tests/run-with-compiler/i5965.scala @@ -9,15 +9,15 @@ object Test { '[List] val list = bound('{List(1, 2, 3)}) println(list.show) - println(list.run) + println(run(list)) val opt = bound('{Option(4)}) println(opt.show) - println(opt.run) + println(run(opt)) val map = bound('{Map(4 -> 1)}) println(map.show) - println(map.run) + println(run(map)) } def bound[T: Type, S[_]: Type](x: Expr[S[T]]): Expr[S[T]] = '{ diff --git a/tests/run-with-compiler/i5965b.scala b/tests/run-with-compiler/i5965b.scala index e9f260958d1b..fc1fc9eb0a59 100644 --- a/tests/run-with-compiler/i5965b.scala +++ b/tests/run-with-compiler/i5965b.scala @@ -10,15 +10,15 @@ object Test { '[List] val list = bound('{List(1, 2, 3)}) println(list.show) - println(list.run) + println(run(list)) val opt = bound('{Option(4)}) println(opt.show) - println(opt.run) + println(run(opt)) val map = bound('{Map(4 -> 1)}) println(map.show) - println(map.run) + println(run(map)) } def bound[T: Type, S[_]: Type](x: Expr[S[T]]): Expr[S[T]] = '{ diff --git a/tests/run-with-compiler/quote-ackermann-1.scala b/tests/run-with-compiler/quote-ackermann-1.scala index 3e9b4c281d01..064322a65816 100644 --- a/tests/run-with-compiler/quote-ackermann-1.scala +++ b/tests/run-with-compiler/quote-ackermann-1.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - val ack3 = ackermann(3).run + val ack3 = run { ackermann(3) } println(ack3(1)) println(ack3(2)) println(ack3(3)) diff --git a/tests/run-with-compiler/quote-fun-app-1.scala b/tests/run-with-compiler/quote-fun-app-1.scala index d99b03cc578a..c028b4fa27c7 100644 --- a/tests/run-with-compiler/quote-fun-app-1.scala +++ b/tests/run-with-compiler/quote-fun-app-1.scala @@ -4,7 +4,9 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - val f = f1.run + val f = run { + f1 + } println(f(42)) println(f(43)) } diff --git a/tests/run-with-compiler/quote-owners-2.scala b/tests/run-with-compiler/quote-owners-2.scala index 0b19e8a32b3f..6ead29442eba 100644 --- a/tests/run-with-compiler/quote-owners-2.scala +++ b/tests/run-with-compiler/quote-owners-2.scala @@ -5,7 +5,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) val q = f(g(Type.IntTag)) - println(q.run) + println(run(q)) println(q.show) } diff --git a/tests/run-with-compiler/quote-owners.scala b/tests/run-with-compiler/quote-owners.scala index 9a6f4bbd7d6d..9811c4bcebde 100644 --- a/tests/run-with-compiler/quote-owners.scala +++ b/tests/run-with-compiler/quote-owners.scala @@ -4,7 +4,7 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) val q = f - println(q.run) + println(run(q)) println(q.show) } diff --git a/tests/run-with-compiler/quote-run-b.scala b/tests/run-with-compiler/quote-run-b.scala index 71ba388be3cd..082317145a64 100644 --- a/tests/run-with-compiler/quote-run-b.scala +++ b/tests/run-with-compiler/quote-run-b.scala @@ -9,7 +9,7 @@ object Test { } println() - val lambda = lambdaExpr.run + val lambda = run(lambdaExpr) lambda(4) lambda(5) } diff --git a/tests/run-with-compiler/quote-run-c.scala b/tests/run-with-compiler/quote-run-c.scala index ddb6df723e8c..61606ce43bae 100644 --- a/tests/run-with-compiler/quote-run-c.scala +++ b/tests/run-with-compiler/quote-run-c.scala @@ -16,9 +16,9 @@ object Test { } new A } - println(classExpr.run) - println(classExpr.run.getClass == classExpr.run.getClass) - println(classExpr2.run) - println(classExpr2.run.getClass) + println(run(classExpr)) + println(run(classExpr).getClass == run(classExpr).getClass) + println(run(classExpr2)) + println(run(classExpr2).getClass) } } diff --git a/tests/run-with-compiler/quote-run-constants.scala b/tests/run-with-compiler/quote-run-constants.scala index 837fb8834499..b69247dcd3f8 100644 --- a/tests/run-with-compiler/quote-run-constants.scala +++ b/tests/run-with-compiler/quote-run-constants.scala @@ -6,21 +6,21 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def run[T](expr: Expr[T]): Unit = println(expr.run) + def runAndPrint[T](expr: Expr[T]): Unit = println(run(expr)) def show[T](expr: Expr[T]): Unit = println(expr.show) - run(true) - run('a') - run('\n') - run('"') - run('\'') - run('\\') - run(1) - run(2) - run(3L) - run(4.0f) - run(5.0d) - run("xyz") + runAndPrint(true) + runAndPrint('a') + runAndPrint('\n') + runAndPrint('"') + runAndPrint('\'') + runAndPrint('\\') + runAndPrint(1) + runAndPrint(2) + runAndPrint(3L) + runAndPrint(4.0f) + runAndPrint(5.0d) + runAndPrint("xyz") println("======") diff --git a/tests/run-with-compiler/quote-run-many.scala b/tests/run-with-compiler/quote-run-many.scala index 2a4644f523df..c788f8fb5d37 100644 --- a/tests/run-with-compiler/quote-run-many.scala +++ b/tests/run-with-compiler/quote-run-many.scala @@ -9,6 +9,8 @@ object Test { 2 + a } for (i <- 0 to 200) - expr(i).run + run { + expr(i) + } } } diff --git a/tests/run-with-compiler/quote-run-staged-interpreter.scala b/tests/run-with-compiler/quote-run-staged-interpreter.scala index 57f6fe6d128c..e6babd0f6287 100644 --- a/tests/run-with-compiler/quote-run-staged-interpreter.scala +++ b/tests/run-with-compiler/quote-run-staged-interpreter.scala @@ -36,7 +36,9 @@ object Test { println(res1.show) - val fn = res1.run + val fn = run { + res1 + } println(fn(0)) println(fn(2)) println(fn(3)) @@ -45,12 +47,16 @@ object Test { val res2 = compile(letExp, Map(), false) println(res2.show) - println(res2.run) + println(run { + res2 + }) println("---") val res3 = compile(letExp, Map(), true) println(res3.show) - println(res3.run) + println(run { + res3 + }) } } diff --git a/tests/run-with-compiler/quote-run-with-settings.scala b/tests/run-with-compiler/quote-run-with-settings.scala index 5e73f65dfafd..a77029c9f349 100644 --- a/tests/run-with-compiler/quote-run-with-settings.scala +++ b/tests/run-with-compiler/quote-run-with-settings.scala @@ -12,7 +12,7 @@ object Test { 2 + a } println(expr.show) - println(expr.run) + println(run(expr)) println() val outDir = Paths.get("out/out-quoted-1") @@ -23,7 +23,7 @@ object Test { { implicit val settings = Toolbox.Settings.make(outDir = Some(outDir.toString)) implicit val toolbox2: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - println(expr.run) + println(run(expr)) assert(Files.exists(classFile)) } } diff --git a/tests/run-with-compiler/quote-run.scala b/tests/run-with-compiler/quote-run.scala index b7d38de71b11..b0d4fa33702b 100644 --- a/tests/run-with-compiler/quote-run.scala +++ b/tests/run-with-compiler/quote-run.scala @@ -8,8 +8,8 @@ object Test { println("foo") 2 + a } - println(expr.run) - println(expr.run) + println(run(expr)) + println(run(expr)) println(expr.show) } } diff --git a/tests/run-with-compiler/quote-var.scala b/tests/run-with-compiler/quote-var.scala index 02a79410cfb8..46b90e8306f8 100644 --- a/tests/run-with-compiler/quote-var.scala +++ b/tests/run-with-compiler/quote-var.scala @@ -31,7 +31,10 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - println(test1().run) + val res = run { + test1() + } + println(res) } } diff --git a/tests/run-with-compiler/shonan-hmm-simple.scala b/tests/run-with-compiler/shonan-hmm-simple.scala index 3b5a0373159a..1c486d037d1f 100644 --- a/tests/run-with-compiler/shonan-hmm-simple.scala +++ b/tests/run-with-compiler/shonan-hmm-simple.scala @@ -147,7 +147,7 @@ object Test { vec2.map(_.toExpr) ) println(resCode1.show) - println(resCode1.run) + println(run(resCode1)) println() val blasExprIntExpr = new Blas1(new RingIntExpr, new ExprVecOps) @@ -162,7 +162,7 @@ object Test { } } println(resCode2.show) - println(resCode2.run.apply(arr1, arr2)) + println(run(resCode2).apply(arr1, arr2)) println() val blasStaticIntPVExpr = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) @@ -171,7 +171,7 @@ object Test { vec2.map(i => Sta(i)) ).expr println(resCode3.show) - println(resCode3.run) + println(run(resCode3)) println() val blasExprIntPVExpr = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) @@ -187,7 +187,7 @@ object Test { } println(resCode4.show) - println(resCode4.run.apply(arr1)) + println(run(resCode4).apply(arr1)) println() import Complex.isLiftable @@ -204,7 +204,7 @@ object Test { } } println(resCode5.show) - println(resCode5.run.apply(cmpxArr1)) + println(run(resCode5).apply(cmpxArr1)) println() val RingPVInt = new RingPV[Int](new RingInt, new RingIntExpr) diff --git a/tests/run-with-compiler/staged-tuples/Test.scala b/tests/run-with-compiler/staged-tuples/Test.scala index c9b3f031628d..2ab1843db224 100644 --- a/tests/run-with-compiler/staged-tuples/Test.scala +++ b/tests/run-with-compiler/staged-tuples/Test.scala @@ -1,3 +1,4 @@ +import scala.quoted.run import scala.internal.StagedTuple._ object Test { @@ -5,22 +6,22 @@ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - assert(fromArrayStaged('{ Array.empty[Object] }, Some(0)).run.==(())) - assert(fromArrayStaged[Tuple1[String]]('{ Array[Object]("a") }, Some(1)).run == Tuple1("a")) - assert(fromArrayStaged[(String, String)]('{ Array[Object]("a", "b") }, Some(2)).run == ("a", "b")) - assert(fromArrayStaged[(String, String, String)]('{ Array[Object]("a", "b", "c") }, Some(3)).run == ("a", "b", "c")) + assert(run(fromArrayStaged('{ Array.empty[Object] }, Some(0))).==(())) + assert(run(fromArrayStaged[Tuple1[String]]('{ Array[Object]("a") }, Some(1))) == Tuple1("a")) + assert(run(fromArrayStaged[(String, String)]('{ Array[Object]("a", "b") }, Some(2))) == ("a", "b")) + assert(run(fromArrayStaged[(String, String, String)]('{ Array[Object]("a", "b", "c") }, Some(3))) == ("a", "b", "c")) - assert(headStaged[Tuple1[String]]('{ Tuple1("a") }, Some(1)).run == "a") - assert(headStaged[(String, String)]('{ ("a", "b") }, Some(2)).run == "a") - assert(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3)).run == "a") + assert(run(headStaged[Tuple1[String]]('{ Tuple1("a") }, Some(1))) == "a") + assert(run(headStaged[(String, String)]('{ ("a", "b") }, Some(2))) == "a") + assert(run(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == "a") - assert(tailStaged[Tuple1[String]]('{ Tuple1("a") }, Some(1)).run == (())) - assert(tailStaged[(String, String)]('{ ("a", "b") }, Some(2)).run == Tuple1("b")) - assert(tailStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3)).run == ("b", "c")) + assert(run(tailStaged[Tuple1[String]]('{ Tuple1("a") }, Some(1))) == (())) + assert(run(tailStaged[(String, String)]('{ ("a", "b") }, Some(2))) == Tuple1("b")) + assert(run(tailStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == ("b", "c")) - assert(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3)).run == "a") - assert(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3)).run == "a") - assert(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3)).run == "a") + assert(run(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == "a") + assert(run(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == "a") + assert(run(headStaged[(String, String, String)]('{ ("a", "b", "c") }, Some(3))) == "a") } } diff --git a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala index f494558779f2..d88a0f0bed63 100644 --- a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala +++ b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala @@ -12,16 +12,22 @@ object Macros { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) // 2 is a lifted constant val show1 = power(2, 3.0).show - val run1 = power(2, 3.0).run + val run1 = run { + power(2, 3.0) + } // n is a lifted constant val n = 2 val show2 = power(n, 4.0).show - val run2 = power(n, 4.0).run + val run2 = run { + power(n, 4.0) + } // n is a constant in a quote val show3 = power('{2}, 5.0).show - val run3 = power('{2}, 5.0).run + val run3 = run { + power('{2}, 5.0) + } // n2 is clearly not a constant // FIXME