Skip to content

Commit 10d3078

Browse files
committed
Remove scala.quoted.show.apply and use Expr.show
`scala.quoted.show.apply` was only intorduced to reduce the diff in the tests. Instead we use the equivalent `run(expr.show.toExpr)` notation explicitly. This has the added advantage of showing explicitly where new compiler runs are located.
1 parent 2a91054 commit 10d3078

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+91
-102
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
scala> implicit def toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
22
def toolbox: quoted.Toolbox
3+
scala> import scala.quoted._
34
scala> val v = '{ (if true then Some(1) else None).map(v => v+1) }
45
val v: quoted.Expr[Option[Int]] = Expr(<pickled tasty>)
5-
scala> scala.quoted.show(v)
6+
scala> scala.quoted.run(v.show.toExpr)
67
val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1)))
78
scala> scala.quoted.run(v)
89
val res1: Option[Int] = Some(2)

library/src/scala/quoted/show/package.scala

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/disabled/reflect/run/position-val-def.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Test {
1010
def test(expr: String): Unit = {
1111
val t = toolbox.parse(expr)
1212
println(expr)
13-
println(show(t, printPositions = true))
13+
println(run(t, printPositions = true.show.toExpr))
1414
println()
1515
}
1616
val tests = """

tests/run-with-compiler/i3823-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object Test {
55
val z: $t = $x
66
}
77
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
8-
println(show(f('{2})(Type.IntTag)))
8+
println(run(f('{2})(Type.IntTag).show.toExpr))
99
}
1010
}

tests/run-with-compiler/i3823-c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object Test {
55
val z = $x
66
}
77
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
8-
println(show(f('{2})(Type.IntTag)))
8+
println(run(f('{2})(Type.IntTag).show.toExpr))
99
}
1010
}

tests/run-with-compiler/i3823.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object Test {
55
val z: $t = $x
66
}
77
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
8-
println(show(f('{2})('[Int])))
8+
println(run(f('{2})('[Int]).show.toExpr))
99
}
1010
}

tests/run-with-compiler/i3847-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ object Test {
1818
import Arrays._
1919
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}
2020
val arr: Expr[Array[List[Int]]] = Array[List[Int]](List(1, 2, 3)).toExpr
21-
println(show(arr))
21+
println(run(arr.show.toExpr))
2222
}
2323
}

tests/run-with-compiler/i3847.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ object Test {
1818
import Arrays._
1919
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}
2020
val arr: Expr[Array[Int]] = Array[Int](1, 2, 3).toExpr
21-
println(show(arr))
21+
println(run(arr.show.toExpr))
2222
}
2323
}

tests/run-with-compiler/i3876-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ object Test {
1111
}
1212

1313
println(run(f2(x)))
14-
println(show(f2(x)))
14+
println(run(f2(x).show.toExpr))
1515
}
1616
}

tests/run-with-compiler/i3876-c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ object Test {
1111
}
1212

1313
println(run(f3(x)))
14-
println(show(f3(x))) // TODO improve printer
14+
println(run(f3(x).show.toExpr)) // TODO improve printer
1515
}
1616
}

tests/run-with-compiler/i3876-d.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
inlineLambda
1010
}
1111
println(run(f4(x)))
12-
println(show(f4(x)))
12+
println(run(f4(x).show.toExpr))
1313
}
1414

1515
inline def inlineLambda <: Int => Int = x => x + x

tests/run-with-compiler/i3876-e.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
inlineLambda
1010
}
1111
println(run(f4(x)))
12-
println(show(f4(x)))
12+
println(run(f4(x).show.toExpr))
1313
}
1414

1515
inline def inlineLambda <: Int => Int = x => x + x

tests/run-with-compiler/i3876.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ object Test {
88
val f: Expr[Int => Int] = '{ (x: Int) => x + x }
99

1010
println(run(f(x)))
11-
println(show(f(x)))
11+
println(run(f(x).show.toExpr))
1212
}
1313
}

tests/run-with-compiler/i3946.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object Test {
33
def main(args: Array[String]): Unit = {
44
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
55
val u: Expr[Unit] = '{}
6-
println(show(u))
6+
println(run(u.show.toExpr))
77
println(run(u))
88
}
99
}

tests/run-with-compiler/i4044a.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Foo {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val e: Expr[Int] = '{3}
77
val q = '{ ${ '{ $e } } }
8-
println(show(q))
8+
println(run(q.show.toExpr))
99
}
1010
}
1111

tests/run-with-compiler/i4044b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ object Test {
2222
def main(args: Array[String]): Unit = {
2323
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
2424
val q = VarRef('{4})(varRef => '{ ${varRef.update('{3})}; ${varRef.expr} })
25-
println(show(q))
25+
println(run(q.show.toExpr))
2626
}
2727
}

tests/run-with-compiler/i4044c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Foo {
44
def foo: Unit = {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val q = '{ ${ '{ ${ '{ 5 } } } } }
7-
println(show(q))
7+
println(run(q.show.toExpr))
88
}
99
}
1010

tests/run-with-compiler/i4044e.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Foo {
77
val f: Expr[Int] = '{5}
88
val t: Type[Int] = '[Int]
99
val q = '{ ${ '{ ($e + $f).asInstanceOf[$t] } } }
10-
println(show(q))
10+
println(run(q.show.toExpr))
1111
}
1212
}
1313

tests/run-with-compiler/i4044f.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Foo {
1414
foo('{e1 + $u}, '{f1})
1515
}
1616
}
17-
println(show(q))
17+
println(run(q.show.toExpr))
1818
}
1919
}
2020

tests/run-with-compiler/i4350.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Foo[T: Type] {
88
object Test {
99
def main(args: Array[String]): Unit = {
1010
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
11-
println(show((new Foo[Object]).q))
12-
println(show((new Foo[String]).q))
11+
println(run((new Foo[Object]).q.show.toExpr))
12+
println(run((new Foo[String]).q.show.toExpr))
1313
}
1414
}

tests/run-with-compiler/i5144.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Test {
1010

1111
def main(args: Array[String]): Unit = {
1212
val p = peval1()
13-
println(show(p))
13+
println(run(p.show.toExpr))
1414
}
1515

1616
}

tests/run-with-compiler/i5152.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Test {
1010

1111
def main(args: Array[String]): Unit = {
1212
val p = peval1()
13-
println(show(p))
13+
println(run(p.show.toExpr))
1414
}
1515

1616
}

tests/run-with-compiler/i5161.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ object Test {
2626
val test = Add(Int2(1), Int2(1))
2727
val res = evalTest(test)
2828
println("run : " + run(res))
29-
println("show : " + show(res))
29+
println("show : " + run(res.show.toExpr))
3030
}
3131
}

tests/run-with-compiler/i5161b.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ object Test {
99
if (x.isInstanceOf[Some[_]]) Option(1)
1010
else None
1111
}
12-
println("show0 : " + show(res))
12+
println("show0 : " + run(res.show.toExpr))
1313
println("run1 : " + run(res))
1414
println("run2 : " + run(res))
15-
println("show3 : " + show(res))
15+
println("show3 : " + run(res.show.toExpr))
1616
}
1717
}

tests/run-with-compiler/i5247.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import scala.quoted._
22
object Test {
33
def main(args: Array[String]): Unit = {
44
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
5-
println(show(foo[Object]))
6-
println(show(bar[Object]))
5+
println(run(foo[Object].show.toExpr))
6+
println(run(bar[Object].show.toExpr))
77
}
88
def foo[H : Type]: Expr[H] = {
99
val t = '[H]

tests/run-with-compiler/i5965.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ object Test {
88
def main(args: Array[String]): Unit = {
99
'[List]
1010
val list = bound('{List(1, 2, 3)})
11-
println(show(list))
11+
println(run(list.show.toExpr))
1212
println(run(list))
1313

1414
val opt = bound('{Option(4)})
15-
println(show(opt))
15+
println(run(opt.show.toExpr))
1616
println(run(opt))
1717

1818
val map = bound('{Map(4 -> 1)})
19-
println(show(map))
19+
println(run(map.show.toExpr))
2020
println(run(map))
2121
}
2222

tests/run-with-compiler/i5965b.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ object Test {
99

1010
'[List]
1111
val list = bound('{List(1, 2, 3)})
12-
println(show(list))
12+
println(run(list.show.toExpr))
1313
println(run(list))
1414

1515
val opt = bound('{Option(4)})
16-
println(show(opt))
16+
println(run(opt.show.toExpr))
1717
println(run(opt))
1818

1919
val map = bound('{Map(4 -> 1)})
20-
println(show(map))
20+
println(run(map.show.toExpr))
2121
println(run(map))
2222
}
2323

tests/run-with-compiler/i5997.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ object Test {
33
def main(args: Array[String]): Unit = {
44
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
55
val v = '{ (if true then Some(1) else None).map(v => v+1) }
6-
println(show(v))
6+
println(run(v.show.toExpr))
77
}
88
}

tests/run-with-compiler/quote-function-applied-to.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import quoted._
1+
import scala.quoted._
22

33
object Test {
44
def main(args: Array[String]): Unit = {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
6+
def show(expr: Expr[_]): String = run(expr.show.toExpr)
67
println(show(('{ () => x(0) }).apply()))
78
println(show(('{ (x1: Int) => x1 }).apply('{x(1)})))
89
println(show(('{ (x1: Int, x2: Int) => x1 + x2 }).apply('{x(1)}, '{x(2)})))

tests/run-with-compiler/quote-macro-in-splice/quoted_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object Test {
1212
'{ y + $b }
1313
}
1414
}
15-
println(show(x))
15+
println(run(x.show.toExpr))
1616
}
1717

1818
}

tests/run-with-compiler/quote-nested-1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ object Test {
44
def main(args: Array[String]): Unit = {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val q = '{ '{3} }
7-
println(show(q))
7+
println(run(q.show.toExpr))
88
}
99
}

tests/run-with-compiler/quote-nested-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ object Test {
99
'{${a}}
1010
}
1111

12-
println(show(q))
12+
println(run(q.show.toExpr))
1313
}
1414
}

tests/run-with-compiler/quote-nested-3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ object Test {
1414
x
1515
}
1616

17-
println(show(q))
17+
println(run(q.show.toExpr))
1818
}
1919
}

tests/run-with-compiler/quote-nested-4.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ object Test {
99
t
1010
}
1111

12-
println(show(q))
12+
println(run(q.show.toExpr))
1313
}
1414
}

tests/run-with-compiler/quote-nested-5.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ object Test {
1212

1313
}
1414

15-
println(show(q))
15+
println(run(q.show.toExpr))
1616
}
1717
}

tests/run-with-compiler/quote-owners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Test {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val q = f
77
println(run(q))
8-
println(show(q))
8+
println(run(q.show.toExpr))
99
}
1010

1111
def f: Expr[Int] = '{

tests/run-with-compiler/quote-run-2.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ object Test {
1010
else if (n % 2 == 0) '{ { val y = $x * $x; ${powerCode(n / 2, 'y)} } }
1111
else '{ $x * ${powerCode(n - 1, x)} }
1212

13-
println(show(powerCode(0, '{5})))
14-
println(show(powerCode(1, '{5})))
15-
println(show(powerCode(2, '{5})))
16-
println(show(powerCode(3, '{5})))
17-
println(show(powerCode(22, '{5})))
13+
println(run(powerCode(0, '{5}).show.toExpr))
14+
println(run(powerCode(1, '{5}).show.toExpr))
15+
println(run(powerCode(2, '{5}).show.toExpr))
16+
println(run(powerCode(3, '{5}).show.toExpr))
17+
println(run(powerCode(22, '{5}).show.toExpr))
1818
}
1919
}

tests/run-with-compiler/quote-run-constants.scala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Test {
77
def main(args: Array[String]): Unit = {
88
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
99
def runAndPrint[T](expr: Expr[T]): Unit = println(run(expr))
10-
def showAndPrint[T](expr: Expr[T]): Unit = println(show(expr))
10+
def show[T](expr: Expr[T]): Unit = println(run(expr.show.toExpr))
1111

1212
runAndPrint(true)
1313
runAndPrint('a')
@@ -24,20 +24,20 @@ object Test {
2424

2525
println("======")
2626

27-
showAndPrint(true)
28-
showAndPrint('a')
29-
showAndPrint('\n')
30-
showAndPrint('"')
31-
showAndPrint('\'')
32-
showAndPrint('\\')
33-
showAndPrint(1)
34-
showAndPrint(2)
35-
showAndPrint(3L)
36-
showAndPrint(4.0f)
37-
showAndPrint(5.0d)
38-
showAndPrint("xyz")
39-
showAndPrint("\n\\\"'")
40-
showAndPrint("""abc
27+
show(true)
28+
show('a')
29+
show('\n')
30+
show('"')
31+
show('\'')
32+
show('\\')
33+
show(1)
34+
show(2)
35+
show(3L)
36+
show(4.0f)
37+
show(5.0d)
38+
show("xyz")
39+
show("\n\\\"'")
40+
show("""abc
4141
xyz""")
4242
}
4343
}

0 commit comments

Comments
 (0)