Skip to content

Commit 2ca5297

Browse files
committed
Avoid accidental conversion from ${ x } to x.unary_~ and back
1 parent 46c9c1d commit 2ca5297

File tree

160 files changed

+435
-423
lines changed

Some content is hidden

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

160 files changed

+435
-423
lines changed

bench/tests/power-macro/PowerMacro.scala

+3-3
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] =
88
if (n == 0) '{1.0}
9-
else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '{y}) }
10-
else '{ ~x * ~powerCode(n - 1, x) }
9+
else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode(n / 2, '{y})} }
10+
else '{ $x * ${powerCode(n - 1, x)} }
1111

1212
}

compiler/src/dotty/tools/dotc/ast/Desugar.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1319,9 +1319,9 @@ object desugar {
13191319
else
13201320
Apply(ref(defn.QuotedExpr_applyR), t)
13211321
case Splice(expr) =>
1322-
Select(expr, nme.UNARY_~)
1322+
Select(expr, nme.splice)
13231323
case TypSplice(expr) =>
1324-
Select(expr, tpnme.UNARY_~)
1324+
Select(expr, tpnme.splice)
13251325
case InterpolatedString(id, segments) =>
13261326
val strs = segments map {
13271327
case ts: Thicket => ts.trees.head

compiler/src/dotty/tools/dotc/core/Definitions.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -707,16 +707,16 @@ class Definitions {
707707
def QuotedExprModule(implicit ctx: Context): Symbol = QuotedExprClass.companionModule
708708
lazy val QuotedExpr_applyR: TermRef = QuotedExprModule.requiredMethodRef(nme.apply)
709709
def QuotedExpr_apply(implicit ctx: Context): Symbol = QuotedExpr_applyR.symbol
710-
lazy val QuotedExpr_~ : TermSymbol = QuotedExprClass.requiredMethod(nme.UNARY_~)
710+
lazy val QuotedExpr_splice : TermSymbol = QuotedExprClass.requiredMethod(nme.splice)
711711

712712
lazy val QuotedExprsModule: TermSymbol = ctx.requiredModule("scala.quoted.Exprs")
713713
def QuotedExprsClass(implicit ctx: Context): ClassSymbol = QuotedExprsModule.asClass
714714

715715
lazy val QuotedTypeType: TypeRef = ctx.requiredClassRef("scala.quoted.Type")
716716
def QuotedTypeClass(implicit ctx: Context): ClassSymbol = QuotedTypeType.symbol.asClass
717717

718-
lazy val QuotedType_spliceR: TypeRef = QuotedTypeClass.requiredType(tpnme.UNARY_~).typeRef
719-
def QuotedType_~ : Symbol = QuotedType_spliceR.symbol
718+
lazy val QuotedType_spliceR: TypeRef = QuotedTypeClass.requiredType(tpnme.splice).typeRef
719+
def QuotedType_splice : Symbol = QuotedType_spliceR.symbol
720720

721721
lazy val QuotedTypeModuleType: TermRef = ctx.requiredModuleRef("scala.quoted.Type")
722722
def QuotedTypeModule(implicit ctx: Context): Symbol = QuotedTypeModuleType.symbol

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
328328
if (name.isTypeName) typeText(txt)
329329
else txt
330330
case tree @ Select(qual, name) =>
331-
if (tree.hasType && tree.symbol == defn.QuotedExpr_~) keywordStr("${") ~ toTextLocal(qual) ~ keywordStr("}")
332-
else if (tree.hasType && tree.symbol == defn.QuotedType_~) typeText("${") ~ toTextLocal(qual) ~ typeText("}")
331+
if (tree.hasType && tree.symbol == defn.QuotedExpr_splice) keywordStr("${") ~ toTextLocal(qual) ~ keywordStr("}")
332+
else if (tree.hasType && tree.symbol == defn.QuotedType_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}")
333333
else if (qual.isType) toTextLocal(qual) ~ "#" ~ typeText(toText(name))
334334
else toTextLocal(qual) ~ ("." ~ nameIdText(tree) provided name != nme.CONSTRUCTOR)
335335
case tree: This =>

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ class ReifyQuotes extends MacroTransform {
129129

130130
def mkTagSymbolAndAssignType(spliced: TermRef): TypeDef = {
131131
val splicedTree = tpd.ref(spliced)
132-
val rhs = transform(splicedTree.select(tpnme.UNARY_~))
132+
val rhs = transform(splicedTree.select(tpnme.splice))
133133
val alias = ctx.typeAssigner.assignType(untpd.TypeBoundsTree(rhs, rhs), rhs, rhs)
134134
val local = ctx.newSymbol(
135135
owner = ctx.owner,
136136
name = UniqueName.fresh((splicedTree.symbol.name.toString + "$_~").toTermName).toTypeName,
137137
flags = Synthetic,
138-
info = TypeAlias(splicedTree.tpe.select(tpnme.UNARY_~)),
138+
info = TypeAlias(splicedTree.tpe.select(tpnme.splice)),
139139
coord = spliced.termSymbol.coord).asType
140140

141141
ctx.typeAssigner.assignType(untpd.TypeDef(local.name, alias), local)
@@ -353,11 +353,11 @@ class ReifyQuotes extends MacroTransform {
353353

354354
case tree: TypeTree if tree.tpe.typeSymbol.isSplice =>
355355
val splicedType = tree.tpe.stripTypeVar.asInstanceOf[TypeRef].prefix.termSymbol
356-
transformSplice(ref(splicedType).select(tpnme.UNARY_~).withSpan(tree.span))
356+
transformSplice(ref(splicedType).select(tpnme.splice).withSpan(tree.span))
357357

358358
case tree: RefTree if isCaptured(tree.symbol, level) =>
359359
val t = capturers(tree.symbol).apply(tree)
360-
transformSplice(t.select(if (tree.isTerm) nme.UNARY_~ else tpnme.UNARY_~))
360+
transformSplice(t.select(if (tree.isTerm) nme.splice else tpnme.splice))
361361

362362
case tree: DefDef if tree.symbol.is(Macro) && level == 0 =>
363363
// Shrink size of the tree. The methods have already been inlined.

compiler/src/dotty/tools/dotc/transform/Staging.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class Staging extends MacroTransform {
301301
| The access would be accepted with the right type tag, but
302302
| ${ctx.typer.missingArgMsg(tag, reqType, "")}""")
303303
case _ =>
304-
Some(tag.select(tpnme.UNARY_~))
304+
Some(tag.select(tpnme.splice))
305305
}
306306
}
307307
case _ =>

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,5 @@ class SymUtils(val self: Symbol) extends AnyVal {
162162

163163
/** Is symbol a splice operation? */
164164
def isSplice(implicit ctx: Context): Boolean =
165-
self == defn.QuotedExpr_~ || self == defn.QuotedType_~
165+
self == defn.QuotedExpr_splice || self == defn.QuotedType_splice
166166
}

compiler/src/dotty/tools/dotc/typer/Implicits.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ trait Implicits { self: Typer =>
669669
case t @ TypeRef(NoPrefix, _) =>
670670
inferImplicit(defn.QuotedTypeType.appliedTo(t), EmptyTree, span) match {
671671
case SearchSuccess(tag, _, _) if tag.tpe.isStable =>
672-
tag.tpe.select(defn.QuotedType_~)
672+
tag.tpe.select(defn.QuotedType_splice)
673673
case _ =>
674674
ok = false
675675
t

compiler/test-resources/repl/i5551

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
scala> import scala.quoted._
22

3-
scala> def assertImpl(expr: Expr[Boolean]) = '{ if !(~expr) then throw new AssertionError("failed assertion")}
3+
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)

library/src-bootstrapped/scala/quoted/package.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package object quoted {
99
implicit class ListOfExprOps[T](val list: List[Expr[T]]) extends AnyVal {
1010
def toExprOfList(implicit ev: Type[T]): Expr[List[T]] = {
1111
def rec(list: List[Expr[T]]): Expr[List[T]] = list match {
12-
case x :: xs => '{ (~x) :: (~rec(xs)) }
12+
case x :: xs => '{ ($x) :: ${rec(xs)} }
1313
case Nil => '{Nil}
1414
}
1515
rec(list)

library/src/scala/quoted/Expr.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package scala.quoted
33
import scala.runtime.quoted.Unpickler.Pickled
44

55
sealed abstract class Expr[+T] {
6-
final def unary_~ : T = throw new Error("~ should have been compiled away")
6+
7+
final def splice: T = throw new Error("splice should have been compiled away")
78

89
/** Evaluate the contents of this expression and return the result.
910
*
@@ -13,6 +14,7 @@ sealed abstract class Expr[+T] {
1314

1415
/** Show a source code like representation of this expression */
1516
final def show(implicit toolbox: Toolbox): String = toolbox.show(this)
17+
1618
}
1719

1820
object Expr {
@@ -146,7 +148,7 @@ object Exprs {
146148
// TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]])
147149
// FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187
148150
// This test does redefine `scala.collection`. Further investigation is needed.
149-
/** An Expr representing `'{(~f).apply(~x1, ..., ~xn)}` but it is beta-reduced when the closure is known */
151+
/** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */
150152
final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] {
151153
override def toString: String = s"Expr($f <applied to> ${args.toList})"
152154
}

library/src/scala/quoted/Type.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.reflect.ClassTag
55
import scala.runtime.quoted.Unpickler.Pickled
66

77
sealed abstract class Type[T] {
8-
type unary_~ = T
8+
type splice = T
99
}
1010

1111
/** Some basic type tags, currently incomplete */

tests/disabled/run/i4803d/App_2.scala

+1-1
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import scala.quoted._
33
object PowerMacro {
44
def powerCode(x: Expr[Double], n: Long): Expr[Double] =
55
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) }
6+
else if (n % 2 == 0) '{ val y = $x * $x; ${powerCode('{y}, n / 2)} }
7+
else '{ $x * ${powerCode(x, n - 1)} }
88
}

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

+1-1
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

+1-1
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/i4044b.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class Test {
88

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

tests/neg/i4774b.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import scala.quoted._
44
object Test {
55
def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{
66
val y: $t = $x;
7-
~loop[$t]( // error
7+
${loop[$t]( // error
88
'{y}
9-
)
9+
)}
1010
}
1111
}

tests/neg/inline-case-objects/Main_2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ object Test {
66
println(fooString(bar.Baz)) // error
77
}
88

9-
inline def fooString(inline x: Any): String = ~Macros.impl(x)
9+
inline def fooString(inline x: Any): String = ${ Macros.impl(x) }
1010

1111
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33

44
object E {
55

6-
inline def eval[T](inline x: E[T]): T = ~impl(x)
6+
inline def eval[T](inline x: E[T]): T = ${ impl(x) }
77

88
def impl[T](x: E[T]): Expr[T] = x.lift
99

tests/neg/inline-option/Main_2.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ object Main {
66
val b: Option[Int] = Some(4)
77
size(b) // error
88

9-
inline def size(inline opt: Option[Int]): Int = ~Macro.impl(opt)
9+
inline def size(inline opt: Option[Int]): Int = ${ Macro.impl(opt) }
1010

11-
inline def size2(inline i: Int): Int = ~Macro.impl(None)
11+
inline def size2(inline i: Int): Int = ${ Macro.impl(None) }
1212

13-
inline def size3(inline i: Int): Int = ~Macro.impl(Some(i))
13+
inline def size3(inline i: Int): Int = ${ Macro.impl(Some(i)) }
1414

1515
}

tests/neg/inline-tuples-1/Main_2.scala

+22-22
Original file line numberDiff line numberDiff line change
@@ -347,27 +347,27 @@ object Test {
347347
)))
348348
}
349349

350-
inline def sum(inline tup: Tuple1[Int]): Int = ~Macros.tup1(tup)
351-
inline def sum(inline tup: Tuple2[Int, Int]): Int = ~Macros.tup2(tup)
352-
inline def sum(inline tup: Tuple3[Int, Int, Int]): Int = ~Macros.tup3(tup)
353-
inline def sum(inline tup: Tuple4[Int, Int, Int, Int]): Int = ~Macros.tup4(tup)
354-
inline def sum(inline tup: Tuple5[Int, Int, Int, Int, Int]): Int = ~Macros.tup5(tup)
355-
inline def sum(inline tup: Tuple6[Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup6(tup)
356-
inline def sum(inline tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup7(tup)
357-
inline def sum(inline tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup8(tup)
358-
inline def sum(inline tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup9(tup)
359-
inline def sum(inline tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup10(tup)
360-
inline def sum(inline tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup11(tup)
361-
inline def sum(inline tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup12(tup)
362-
inline def sum(inline tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup13(tup)
363-
inline def sum(inline tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup14(tup)
364-
inline def sum(inline tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup15(tup)
365-
inline def sum(inline tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup16(tup)
366-
inline def sum(inline tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup17(tup)
367-
inline def sum(inline tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup18(tup)
368-
inline def sum(inline tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup19(tup)
369-
inline def sum(inline tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup20(tup)
370-
inline def sum(inline tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup21(tup)
371-
inline def sum(inline tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ~Macros.tup22(tup)
350+
inline def sum(inline tup: Tuple1[Int]): Int = ${ Macros.tup1(tup) }
351+
inline def sum(inline tup: Tuple2[Int, Int]): Int = ${ Macros.tup2(tup) }
352+
inline def sum(inline tup: Tuple3[Int, Int, Int]): Int = ${ Macros.tup3(tup) }
353+
inline def sum(inline tup: Tuple4[Int, Int, Int, Int]): Int = ${ Macros.tup4(tup) }
354+
inline def sum(inline tup: Tuple5[Int, Int, Int, Int, Int]): Int = ${ Macros.tup5(tup) }
355+
inline def sum(inline tup: Tuple6[Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup6(tup) }
356+
inline def sum(inline tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup7(tup) }
357+
inline def sum(inline tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup8(tup) }
358+
inline def sum(inline tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup9(tup) }
359+
inline def sum(inline tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup10(tup) }
360+
inline def sum(inline tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup11(tup) }
361+
inline def sum(inline tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup12(tup) }
362+
inline def sum(inline tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup13(tup) }
363+
inline def sum(inline tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup14(tup) }
364+
inline def sum(inline tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup15(tup) }
365+
inline def sum(inline tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup16(tup) }
366+
inline def sum(inline tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup17(tup) }
367+
inline def sum(inline tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup18(tup) }
368+
inline def sum(inline tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup19(tup) }
369+
inline def sum(inline tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup20(tup) }
370+
inline def sum(inline tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup21(tup) }
371+
inline def sum(inline tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Int = ${ Macros.tup22(tup) }
372372

373373
}

tests/neg/quote-MacroOverride.scala

+1-1
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ object Test {
99
impl(x)
1010
}
1111

12-
inline def foo2: Unit = ~impl({ // error
12+
inline def foo2: Unit = ${ impl({ // error
1313
val x = 1
1414
x
15-
})
15+
}) }
1616

17-
inline def foo3: Unit = ~impl({ // error
17+
inline def foo3: Unit = ${ impl({ // error
1818
println("foo3")
1919
3
20-
})
20+
}) }
2121

2222
inline def foo4: Unit = ${ // error
2323
println("foo4")

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import scala.quoted._
33
object Macro {
44

55
inline def foo(b: Boolean): Int = { // error
6-
if (b) ~bar(true)
7-
else ~bar(false)
6+
if (b) ${ bar(true) }
7+
else ${ bar(false) }
88
}
99

1010
def bar(b: Boolean): Expr[Int] = if (b) '{1} else '{0}
+2-2
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ object Test {
44

55
inline def foo1: Int = { // error
66
println()
7-
~impl(1.toExpr)
7+
${ impl(1.toExpr) }
88
}
99

1010
inline def foo2: Int = { // error
11-
~impl(1.toExpr)
12-
~impl(2.toExpr)
11+
${ impl(1.toExpr) }
12+
${ impl(2.toExpr) }
1313
}
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

+1-1
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
}

0 commit comments

Comments
 (0)