Skip to content

Commit 1b70eff

Browse files
committed
Update tests to new syntax
1 parent ba0f746 commit 1b70eff

File tree

206 files changed

+661
-675
lines changed

Some content is hidden

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

206 files changed

+661
-675
lines changed

bench/tests/power-macro/PowerMacro.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import scala.quoted.Expr
22

33
object PowerMacro {
44

5-
inline def power(inline n: Long, x: Double) = ~powerCode(n, '(x))
5+
inline def power(inline n: Long, x: Double) = ~powerCode(n, '{x})
66

77
def powerCode(n: Long, x: Expr[Double]): Expr[Double] =
8-
if (n == 0) '(1.0)
9-
else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '(y)) }
8+
if (n == 0) '{1.0}
9+
else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '{y}) }
1010
else '{ ~x * ~powerCode(n - 1, x) }
1111

1212
}

compiler/test-resources/repl/i5551

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ scala> import scala.quoted._
33
scala> def assertImpl(expr: Expr[Boolean]) = '{ if !(~expr) then throw new AssertionError("failed assertion")}
44
def assertImpl(expr: quoted.Expr[Boolean]): quoted.Expr[Unit]
55

6-
scala> inline def assert(expr: => Boolean): Unit = ~ assertImpl('(expr))
6+
scala> inline def assert(expr: => Boolean): Unit = ~ assertImpl('{expr})
77
def assert(expr: => Boolean): Unit
88

99
scala> assert(0 == 0)

tests/disabled/run/i4803d/App_2.scala

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

1313
inline def power2(x: Double) = {
14-
inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('(x), n)
14+
inline def power(x: Double, inline n: Long) = ~PowerMacro.powerCode('{x}, n)
1515
power(x, 2)
1616
}
1717
}

tests/disabled/run/i4803d/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22

33
object PowerMacro {
44
def powerCode(x: Expr[Double], n: Long): Expr[Double] =
5-
if (n == 0) '(1.0)
6-
else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode('(y), n / 2) }
7-
else '{ ~x * ~powerCode(x, n - 1) }
5+
if (n == 0) '{1.0}
6+
else if (n % 2 == 0) '{ val y = $x * $x; ~powerCode('{y}, n / 2) }
7+
else '{ $x * ~powerCode(x, n - 1) }
88
}

tests/disabled/run/xml-interpolation-3/XmlQuote_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ object XmlQuote {
99

1010
implicit object SCOps {
1111
inline def xml(this inline ctx: StringContext)(args: => Any*): Xml =
12-
~XmlQuote.impl(ctx, '(args))
12+
${XmlQuote.impl(ctx, '{args})}
1313
}
1414

1515
def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = {
1616
val string = receiver.parts.mkString("??")
17-
'(new Xml(~string.toExpr, (~args).toList))
17+
'{new Xml(${string.toExpr}, ($args).toList)}
1818
}
1919
}

tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33
import scala.quoted.Toolbox.Default._
44

55
object Macros {
6-
inline def foo(i: => Int): Int = ~fooImpl('(i))
6+
inline def foo(i: => Int): Int = ~fooImpl('{i})
77
def fooImpl(i: Expr[Int]): Expr[Int] = {
88
val y: Int = i.run
99
y.toExpr

tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33
import scala.quoted.Toolbox.Default._
44

55
object Macros {
6-
inline def foo(i: => Int): Int = ~fooImpl('(i))
6+
inline def foo(i: => Int): Int = ~fooImpl('{i})
77
def fooImpl(i: Expr[Int]): Expr[Int] = {
88
val y: Int = i.run
99
y.toExpr

tests/neg/i4044a.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import scala.quoted._
22

33
class Test {
44

5-
val a = '(1)
5+
val a = '{1}
66
'{
77
a // error
8-
~a
9-
'(~a) // error
10-
'( '(~a) ) // error
8+
$a
9+
'{$a} // error
10+
'{ '{$a} } // error
1111
}
1212

1313
}

tests/neg/i4044b.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ class Test {
44

55
'{
66

7-
val b = '(3)
7+
val b = '{3}
88

99
'{
1010
b // error
1111
~(b)
12-
~('(b)) // error
13-
'( '(~b) ) // error
12+
~('{b}) // error
13+
'{ '{$b} } // error
1414
}
1515

1616
}

tests/neg/i4350.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scala.quoted.Type
22

33
class Foo[T] {
4-
'(null.asInstanceOf[T]) // error
4+
'{null.asInstanceOf[T]} // error
55
}

tests/neg/i4433.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
object Foo {
3-
inline def g(inline p: Int => Boolean): Boolean = ~{ // error
4-
if(p(5)) '(true)
5-
else '(false)
3+
inline def g(inline p: Int => Boolean): Boolean = ${ // error
4+
if(p(5)) '{true}
5+
else '{false}
66
}
77
}

tests/neg/i4493-b.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Index[K]
22
object Index {
3-
inline def succ[K](x: K): Unit = ~{ // error
3+
inline def succ[K](x: K): Unit = ${ // error
44
implicit val t: quoted.Type[K] = '[K]
5-
'(new Index[K])
5+
'{new Index[K]}
66
}
77
}

tests/neg/i4493.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Index[K]
22
object Index {
3-
inline def succ[K]: Unit = ~{ // error
3+
inline def succ[K]: Unit = ${ // error
44
implicit val t: quoted.Type[K] = '[K]
5-
'(new Index[K])
5+
'{new Index[K]}
66
}
77
}

tests/neg/i4774b.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import scala.quoted._
33

44
object Test {
55
def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{
6-
val y: ~t = ~x;
7-
~loop[~t]( // error
8-
'(y)
6+
val y: $t = $x;
7+
~loop[$t]( // error
8+
'{y}
99
)
1010
}
1111
}

tests/neg/i4890.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import scala.quoted._
33
object Test {
44
def toExpr(x: Option[String]): Expr[String] = x match {
55
case Some(s) =>
6-
'(s) // error
6+
'{s} // error
77
}
88
}

tests/neg/inline-macro-staged-interpreter/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ trait Op2[T] {
2828
trait Plus2[T] extends Op2[T]
2929
object Plus2 {
3030
implicit case object IPlus extends Plus2[Int] {
31-
def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '(~x + ~y)
31+
def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{$x + $y}
3232
}
3333
}

tests/neg/inline-option/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import scala.quoted._
44
object Macro {
55
def impl(opt: Option[Int]): Expr[Int] = opt match {
66
case Some(i) => i.toExpr
7-
case None => '(-1)
7+
case None => '{-1}
88
}
99
}

tests/neg/quote-0.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ class Test {
44

55
val x: Int = 0
66

7-
'{ '(x + 1) // error: wrong staging level
7+
'{ '{x + 1} // error: wrong staging level
88

9-
'((y: Expr[Int]) => ~y ) // error: wrong staging level
9+
'{(y: Expr[Int]) => $y } // error: wrong staging level
1010

1111
}
1212

13-
'(x + 1) // error: wrong staging level
13+
'{x + 1} // error: wrong staging level
1414

15-
'((y: Expr[Int]) => ~y ) // error: wrong staging level
15+
'{(y: Expr[Int]) => $y } // error: wrong staging level
1616

1717
def f[T](t: Type[T], x: Expr[T]) = '{ // error: wrong staging level
18-
val z2 = ~x
18+
val z2 = $x
1919
}
2020

2121
def g[T](implicit t: Type[T], x: Expr[T]) = '{
22-
val z2 = ~x // ok
22+
val z2 = $x // ok
2323
}
2424

2525
}

tests/neg/quote-MacroOverride.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Test {
66
}
77

88
object B extends A {
9-
inline def f() = ~('()) // error: may not override
9+
inline def f() = ~('{}) // error: may not override
1010
override def g() = () // error: may not override
1111
}
1212

tests/neg/quote-complex-top-splice.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted._
44

55
object Test {
66

7-
inline def foo1: Unit = ~{ // error
7+
inline def foo1: Unit = ${ // error
88
val x = 1
99
impl(x)
1010
}
@@ -19,11 +19,11 @@ object Test {
1919
3
2020
})
2121

22-
inline def foo4: Unit = ~{ // error
22+
inline def foo4: Unit = ${ // error
2323
println("foo4")
2424
impl(1)
2525
}
2626

27-
def impl(i: Int): Expr[Unit] = '()
27+
def impl(i: Int): Expr[Unit] = '{}
2828

2929
}

tests/neg/quote-error-2/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import quoted._
22

33
object Macro_1 {
4-
inline def foo(inline b: Boolean): Unit = ~fooImpl(b)
4+
inline def foo(inline b: Boolean): Unit = ${ fooImpl(b) }
55
def fooImpl(b: Boolean): Expr[Unit] =
6-
'(println(~msg(b)))
6+
'{println(${msg(b)})}
77

88
def msg(b: Boolean): Expr[String] =
9-
if (b) '("foo(true)")
9+
if (b) '{"foo(true)"}
1010
else QuoteError("foo cannot be called with false")
1111

1212
}

tests/neg/quote-error/Macro_1.scala

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

33
object Macro_1 {
4-
inline def foo(inline b: Boolean): Unit = ~fooImpl(b)
4+
inline def foo(inline b: Boolean): Unit = ${fooImpl(b)}
55
def fooImpl(b: Boolean): Expr[Unit] =
6-
if (b) '(println("foo(true)"))
6+
if (b) '{println("foo(true)")}
77
else QuoteError("foo cannot be called with false")
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import quoted._
22

33
object Macro_1 {
4-
inline def foo(inline b: Boolean): Unit = ~fooImpl(b)
4+
inline def foo(inline b: Boolean): Unit = ${fooImpl(b)}
55
def fooImpl(b: Boolean): Expr[Unit] =
6-
if (b) '(println("foo(true)"))
6+
if (b) '{println("foo(true)")}
77
else ???
88
}

tests/neg/quote-interpolator-core-old.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import scala.quoted._
55
object FInterpolation {
66

77
implicit class FInterpolatorHelper(val sc: StringContext) extends AnyVal {
8-
inline def ff(arg1: Any): String = ~fInterpolation(sc, Seq('(arg1))) // error: Inline macro method must be a static method
9-
inline def ff(arg1: Any, arg2: Any): String = ~fInterpolation(sc, Seq('(arg1), '(arg2))) // error: Inline macro method must be a static method
10-
inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ~fInterpolation(sc, Seq('(arg1), '(arg2), '(arg3))) // error: Inline macro method must be a static method
8+
inline def ff(arg1: Any): String = ${fInterpolation(sc, Seq('{arg1}))} // error: Inline macro method must be a static method
9+
inline def ff(arg1: Any, arg2: Any): String = ${fInterpolation(sc, Seq('{arg1}, '{arg2}))} // error: Inline macro method must be a static method
10+
inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ${fInterpolation(sc, Seq('{arg1}, '{arg2}, '{arg3}))} // error: Inline macro method must be a static method
1111
// ...
1212
}
1313

1414
private def liftSeq(args: Seq[Expr[Any]]): Expr[Seq[Any]] = args match {
15-
case x :: xs => '{ (~x) +: ~(liftSeq(xs)) }
16-
case Nil => '(Seq(): Seq[Any])
15+
case x :: xs => '{ ($x) +: ${liftSeq(xs)} }
16+
case Nil => '{Seq(): Seq[Any]}
1717
}
1818

1919
def fInterpolation(sc: StringContext, args: Seq[Expr[Any]]): Expr[String] = {
2020
val str: Expr[String] = sc.parts.mkString("").toExpr
2121
val args1: Expr[Seq[Any]] = liftSeq(args)
22-
'{ (~str).format(~args1: _*) }
22+
'{ $str.format($args1: _*) }
2323
}
2424

2525
def hello = "hello"

tests/neg/quote-macro-2-splices.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ object Macro {
77
else ~bar(false)
88
}
99

10-
def bar(b: Boolean): Expr[Int] = if (b) '(1) else '(0)
10+
def bar(b: Boolean): Expr[Int] = if (b) '{1} else '{0}
1111
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.quoted._
22

33
object Macros {
4-
inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i + 1, '(j)) // error: i + 1 is not a parameter or field reference
5-
def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ~x.toExpr + ~y }
4+
inline def foo(inline i: Int, dummy: Int, j: Int): Int = ~bar(i + 1, '{j}) // error: i + 1 is not a parameter or field reference
5+
def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ~{x.toExpr} + $y }
66
}

tests/neg/quote-macro-splice.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ object Test {
1414

1515
inline def foo3: Int = { // error
1616
val a = 1
17-
~impl('(a))
17+
~impl('{a})
1818
}
1919

2020
inline def foo4: Int = { // error
21-
~impl('(1))
21+
~impl('{1})
2222
1
2323
}
2424

tests/neg/quote-pcp-in-arg.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.quoted._
22

33
object Foo {
4-
inline def foo(x: Int): Int = ~bar('{ '(x); x }) // error
4+
inline def foo(x: Int): Int = ~bar('{ '{x}; x }) // error
55
def bar(i: Expr[Int]): Expr[Int] = i
66
}

tests/neg/quote-splice-interpret-1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import scala.quoted._
33

44
object Macros {
5-
inline def isZero(inline n: Int): Boolean = ~{ // error
6-
if (n == 0) '(true)
7-
else '(false)
5+
inline def isZero(inline n: Int): Boolean = ${ // error
6+
if (n == 0) '{true}
7+
else '{false}
88
}
99
}

tests/neg/quote-spliceNonStaged.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import scala.quoted._
33

44
object Quotes_1 {
55
def printHello: Expr[Unit] = '{ println("Hello") }
6-
~printHello // error
6+
$printHello // error
77
}

tests/neg/quote-this.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class Foo {
1212
}
1313

1414
inline def i(): Unit = ~Foo.impl[Any]('{
15-
'(this) // error
15+
'{this} // error
1616
})
1717

1818
inline def j(that: Foo): Unit = ~Foo.impl[Any]('{
19-
'(that) // error
19+
'{that} // error
2020
})
2121

2222
inline def k(): Unit = ~Foo.impl[Any](this) // error
@@ -25,5 +25,5 @@ class Foo {
2525
}
2626

2727
object Foo {
28-
def impl[T](x: Any): Expr[Unit] = '()
28+
def impl[T](x: Any): Expr[Unit] = '{}
2929
}

0 commit comments

Comments
 (0)