From 4b732cef0741dc303ed2c34a3ceb123c080d2156 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 19 Sep 2019 15:06:55 +0200 Subject: [PATCH 1/2] Replace quoted `toExpr` with `Expr.apply` --- .../changed-features/numeric-literals.md | 2 +- docs/docs/reference/metaprogramming/macros.md | 6 +- .../metaprogramming/tasty-reflect.md | 2 +- .../dotty/internal/StringContextMacro.scala | 2 +- .../scala/quoted/Liftable.scala | 80 ++++++++--------- .../scala/quoted/package.scala | 3 +- library/src/scala/quoted/Expr.scala | 3 + library/src/scala/quoted/autolift.scala | 2 +- .../disabled/pos/quote-whitebox/Macro_1.scala | 2 +- .../GenericNumLits/Even_1.scala | 2 +- .../GenericNumLits/Test_2.scala | 0 .../inline-case-objects/Macro_1.scala | 2 +- tests/neg-macros/inline-option/Macro_1.scala | 2 +- .../quote-macro-complex-arg-0.scala | 2 +- .../GenericNumLits/Even_1.scala | 2 +- tests/neg/BigFloat/BigFloat_1.scala | 4 +- tests/pending/pos/i4987.scala | 5 +- .../pos-macros/quote-whitebox-2/Macro_1.scala | 2 +- tests/pos/i5547.scala | 2 +- tests/pos/i6214.scala | 2 +- tests/pos/quote-lift.scala | 2 +- tests/pos/quote-liftable.scala | 22 ++--- .../tasty-load-tree-1/quoted_1.scala | 6 +- .../tasty-load-tree-2/quoted_1.scala | 6 +- .../Macro_1.scala | 28 +++--- tests/run-macros/i5629/Macro_1.scala | 2 +- tests/run-macros/i6765-b/Macro_1.scala | 2 +- tests/run-macros/i6765-c/Macro_1.scala | 4 +- tests/run-macros/i6765/Macro_1.scala | 2 +- .../inline-case-objects/Macro_1.scala | 2 +- .../Macro_1.scala | 4 +- .../quote-matcher-runtime/quoted_1.scala | 6 +- .../quoted_1.scala | 2 +- .../quoted_1.scala | 2 +- .../quote-matcher-symantics-1/quoted_1.scala | 2 +- .../quote-matcher-symantics-2/quoted_1.scala | 6 +- .../quote-matcher-symantics-3/quoted_1.scala | 4 +- .../quote-type-matcher-2/quoted_1.scala | 2 +- .../quote-type-matcher/quoted_1.scala | 6 +- .../run-macros/reflect-inline/assert_1.scala | 4 +- .../reflect-isFunctionType/macro_1.scala | 8 +- .../reflect-typeChecks/assert_1.scala | 2 +- tests/run-macros/tasty-dealias/quoted_1.scala | 2 +- .../quoted_1.scala | 2 +- .../tasty-macro-positions/quoted_1.scala | 6 +- .../tasty-simplified/quoted_1.scala | 2 +- tests/run-macros/type-show/Macro_1.scala | 2 +- tests/run-staging/i3847-b.scala | 4 +- tests/run-staging/i3847.scala | 4 +- tests/run-staging/i3947.scala | 2 +- tests/run-staging/i3947b.scala | 2 +- tests/run-staging/i3947b2.scala | 2 +- tests/run-staging/i3947b3.scala | 2 +- tests/run-staging/i3947c.scala | 2 +- tests/run-staging/i3947d.scala | 2 +- tests/run-staging/i3947d2.scala | 2 +- tests/run-staging/i3947e.scala | 2 +- tests/run-staging/i3947f.scala | 2 +- tests/run-staging/i3947g.scala | 2 +- tests/run-staging/i3947i.scala | 2 +- tests/run-staging/i3947j.scala | 2 +- tests/run-staging/i4730.scala | 2 +- tests/run-staging/i5161.scala | 2 +- tests/run-staging/i6992/Macro_1.scala | 2 +- tests/run-staging/quote-lib.scala | 88 +++++++++---------- tests/run-staging/quote-lift-BigDecimal.scala | 4 +- tests/run-staging/quote-lift-BigInt.scala | 4 +- .../quote-macro-in-splice/quoted_2.scala | 2 +- tests/run-staging/shonan-hmm-simple.scala | 4 +- tests/run-staging/shonan-hmm/Complex.scala | 2 +- tests/run-staging/shonan-hmm/PV.scala | 2 +- .../staged-tuples/StagedTuple.scala | 10 +-- .../BigFloat/BigFloat_1.scala | 4 +- tests/run-with-compiler/i6201/macro_1.scala | 4 +- tests/run-with-compiler/i6270/Macro_1.scala | 4 +- .../reflect-sourceCode/Macro_1.scala | 2 +- 76 files changed, 218 insertions(+), 215 deletions(-) rename tests/{neg => neg-macros}/GenericNumLits/Even_1.scala (96%) rename tests/{neg => neg-macros}/GenericNumLits/Test_2.scala (100%) diff --git a/docs/docs/reference/changed-features/numeric-literals.md b/docs/docs/reference/changed-features/numeric-literals.md index 1bacaf22a5ec..562db962bf7a 100644 --- a/docs/docs/reference/changed-features/numeric-literals.md +++ b/docs/docs/reference/changed-features/numeric-literals.md @@ -206,7 +206,7 @@ implementation method `fromDigitsImpl`. Here is its definition: case Const(ds) => try { val BigFloat(m, e) = apply(ds) - '{BigFloat(${m.toExpr}, ${e.toExpr})} + '{BigFloat(${Expr(m)}, ${Expr(e)})} } catch { case ex: FromDigits.FromDigitsException => diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 2c394c153bcf..0b97aa385acf 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -228,7 +228,7 @@ import given scala.quoted._ def compile(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match { case Num(n) => - n.toExpr + Expr(n) case Plus(e1, e2) => '{ ${ compile(e1, env) } + ${ compile(e2, env) } } case Var(x) => @@ -241,7 +241,7 @@ Running `compile(letExp, Map())` would yield the following Scala code: ```scala '{ val y = 3; (2 + y) + 4 } ``` -The body of the first clause, `case Num(n) => n.toExpr`, looks suspicious. `n` +The body of the first clause, `case Num(n) => Expr(n)`, looks suspicious. `n` is declared as an `Int`, yet it is converted to an `Expr[Int]` with `toExpr`. Shouldn’t `n` be quoted? In fact this would not work since replacing `n` by `'n` in the clause would not be phase @@ -308,7 +308,7 @@ Using lifting, we can now give the missing definition of `showExpr` in the intro ```scala def showExpr[T](expr: Expr[T]): Expr[String] = { val code: String = expr.show - code.toExpr + Expr(code) } ``` That is, the `showExpr` method converts its `Expr` argument to a string (`code`), and lifts diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index 1bc2cca74570..c33bc14953fb 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -68,7 +68,7 @@ The method `qctx.tasty.Term.seal[T]` provides a way to go back to a `quoted.Expr[Any]`. Note that the type is `Expr[Any]`. Consequently, the type must be set explicitly with a checked `cast` call. If the type does not conform to it an exception will be thrown. In the code above, we could have replaced -`n.toExpr` by `xTree.seal.cast[Int]`. +`Expr(n)` by `xTree.seal.cast[Int]`. ### Obtaining the underlying argument diff --git a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala index 851dd26c6934..bddd67e3176f 100644 --- a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala +++ b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala @@ -751,6 +751,6 @@ object StringContextMacro { } // macro expansion - '{(${parts.mkString.toExpr}).format(${argsExpr}: _*)} + '{(${Expr(parts.mkString)}).format(${argsExpr}: _*)} } } diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index 61fd01e44a69..3a06170c1431 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -47,60 +47,60 @@ object Liftable { given ClassTagIsLiftable[T: Type] : Liftable[ClassTag[T]] = new Liftable[ClassTag[T]] { def toExpr(ct: ClassTag[T]): (given QuoteContext) => Expr[ClassTag[T]] = - '{ ClassTag[T](${ct.runtimeClass.toExpr}) } + '{ ClassTag[T](${Expr(ct.runtimeClass.asInstanceOf[Class[T]])}) } } given ArrayIsLiftable[T: Type: Liftable: ClassTag] : Liftable[Array[T]] = new Liftable[Array[T]] { def toExpr(arr: Array[T]): (given QuoteContext) => Expr[Array[T]] = - '{ Array[T](${arr.toSeq.toExpr}: _*)(${summon[ClassTag[T]].toExpr}) } + '{ Array[T](${Expr(arr.toSeq)}: _*)(${Expr(summon[ClassTag[T]])}) } } given ArrayOfBooleanIsLiftable : Liftable[Array[Boolean]] = new Liftable[Array[Boolean]] { def toExpr(array: Array[Boolean]): (given QuoteContext) => Expr[Array[Boolean]] = if (array.length == 0) '{ Array.emptyBooleanArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfByteIsLiftable : Liftable[Array[Byte]] = new Liftable[Array[Byte]] { def toExpr(array: Array[Byte]): (given QuoteContext) => Expr[Array[Byte]] = if (array.length == 0) '{ Array.emptyByteArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfShortIsLiftable : Liftable[Array[Short]] = new Liftable[Array[Short]] { def toExpr(array: Array[Short]): (given QuoteContext) => Expr[Array[Short]] = if (array.length == 0) '{ Array.emptyShortArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfCharIsLiftable : Liftable[Array[Char]] = new Liftable[Array[Char]] { def toExpr(array: Array[Char]): (given QuoteContext) => Expr[Array[Char]] = if (array.length == 0) '{ Array.emptyCharArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfIntIsLiftable : Liftable[Array[Int]] = new Liftable[Array[Int]] { def toExpr(array: Array[Int]): (given QuoteContext) => Expr[Array[Int]] = if (array.length == 0) '{ Array.emptyIntArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfLongIsLiftable : Liftable[Array[Long]] = new Liftable[Array[Long]] { def toExpr(array: Array[Long]): (given QuoteContext) => Expr[Array[Long]] = if (array.length == 0) '{ Array.emptyLongArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfFloatIsLiftable : Liftable[Array[Float]] = new Liftable[Array[Float]] { def toExpr(array: Array[Float]): (given QuoteContext) => Expr[Array[Float]] = if (array.length == 0) '{ Array.emptyFloatArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given ArrayOfDoubleIsLiftable : Liftable[Array[Double]] = new Liftable[Array[Double]] { def toExpr(array: Array[Double]): (given QuoteContext) => Expr[Array[Double]] = if (array.length == 0) '{ Array.emptyDoubleArray } - else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) } + else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } given iArrayIsLiftable[T: Type](given ltArray: Liftable[Array[T]]): Liftable[IArray[T]] { @@ -120,189 +120,189 @@ object Liftable { given [T: Type: Liftable] : Liftable[Set[T]] = new Liftable[Set[T]] { def toExpr(set: Set[T]): (given QuoteContext) => Expr[Set[T]] = - '{ Set(${set.toSeq.toExpr}: _*) } + '{ Set(${Expr(set.toSeq)}: _*) } } given [T: Type: Liftable, U: Type: Liftable] : Liftable[Map[T, U]] = new Liftable[Map[T, U]] { def toExpr(map: Map[T, U]): (given QuoteContext) => Expr[Map[T, U]] = - '{ Map(${map.toSeq.toExpr}: _*) } + '{ Map(${Expr(map.toSeq)}: _*) } } given [T: Type: Liftable] : Liftable[Option[T]] = new Liftable[Option[T]] { def toExpr(x: Option[T]): (given QuoteContext) => Expr[Option[T]] = x match { - case Some(x) => '{ Some[T](${x.toExpr}) } + case Some(x) => '{ Some[T](${Expr(x)}) } case None => '{ None: Option[T] } } } given [L: Type: Liftable, R: Type: Liftable] : Liftable[Either[L, R]] = new Liftable[Either[L, R]] { def toExpr(x: Either[L, R]): (given QuoteContext) => Expr[Either[L, R]] = x match { - case Left(x) => '{ Left[L, R](${x.toExpr}) } - case Right(x) => '{ Right[L, R](${x.toExpr}) } + case Left(x) => '{ Left[L, R](${Expr(x)}) } + case Right(x) => '{ Right[L, R](${Expr(x)}) } } } given [T1: Type: Liftable] : Liftable[Tuple1[T1]] = new { def toExpr(tup: Tuple1[T1]) = - '{ Tuple1(${tup._1.toExpr}) } + '{ Tuple1(${Expr(tup._1)}) } } given [T1: Type: Liftable, T2: Type: Liftable] : Liftable[Tuple2[T1, T2]] = new { def toExpr(tup: Tuple2[T1, T2]) = - '{ (${tup._1.toExpr}, ${tup._2.toExpr}) } + '{ (${Expr(tup._1)}, ${Expr(tup._2)}) } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable] : Liftable[Tuple3[T1, T2, T3]] = new { def toExpr(tup: Tuple3[T1, T2, T3]) = - '{ (${tup._1.toExpr}, ${tup._2.toExpr}, ${tup._3.toExpr}) } + '{ (${Expr(tup._1)}, ${Expr(tup._2)}, ${Expr(tup._3)}) } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable] : Liftable[Tuple4[T1, T2, T3, T4]] = new { def toExpr(tup: Tuple4[T1, T2, T3, T4]) = - '{ (${tup._1.toExpr}, ${tup._2.toExpr}, ${tup._3.toExpr}, ${tup._4.toExpr}) } + '{ (${Expr(tup._1)}, ${Expr(tup._2)}, ${Expr(tup._3)}, ${Expr(tup._4)}) } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable] : Liftable[Tuple5[T1, T2, T3, T4, T5]] = new { def toExpr(tup: Tuple5[T1, T2, T3, T4, T5]) = { val (x1, x2, x3, x4, x5) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable] : Liftable[Tuple6[T1, T2, T3, T4, T5, T6]] = new { def toExpr(tup: Tuple6[T1, T2, T3, T4, T5, T6]) = { val (x1, x2, x3, x4, x5, x6) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable] : Liftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { def toExpr(tup: Tuple7[T1, T2, T3, T4, T5, T6, T7]) = { val (x1, x2, x3, x4, x5, x6, x7) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable] : Liftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { def toExpr(tup: Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]) = { val (x1, x2, x3, x4, x5, x6, x7, x8) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable] : Liftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { def toExpr(tup: Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable] : Liftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { def toExpr(tup: Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable] : Liftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { def toExpr(tup: Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable] : Liftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { def toExpr(tup: Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable] : Liftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { def toExpr(tup: Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable] : Liftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { def toExpr(tup: Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable] : Liftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { def toExpr(tup: Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable] : Liftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { def toExpr(tup: Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable] : Liftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { def toExpr(tup: Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable] : Liftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { def toExpr(tup: Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable] : Liftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { def toExpr(tup: Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable] : Liftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { def toExpr(tup: Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}, ${x20.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}, ${Expr(x20)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable] : Liftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { def toExpr(tup: Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}, ${x20.toExpr}, ${x21.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}, ${Expr(x20)}, ${Expr(x21)}) } } } given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable, T22: Type: Liftable] : Liftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { def toExpr(tup: Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22) = tup - '{ (${x1.toExpr}, ${x2.toExpr}, ${x3.toExpr}, ${x4.toExpr}, ${x5.toExpr}, ${x6.toExpr}, ${x7.toExpr}, ${x8.toExpr}, ${x9.toExpr}, ${x10.toExpr}, ${x11.toExpr}, ${x12.toExpr}, ${x13.toExpr}, ${x14.toExpr}, ${x15.toExpr}, ${x16.toExpr}, ${x17.toExpr}, ${x18.toExpr}, ${x19.toExpr}, ${x20.toExpr}, ${x21.toExpr}, ${x22.toExpr}) } + '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}, ${Expr(x20)}, ${Expr(x21)}, ${Expr(x22)}) } } } given [H: Type: Liftable, T <: Tuple: Type: Liftable] : Liftable[H *: T] = new { def toExpr(tup: H *: T): (given QuoteContext) => Expr[H *: T] = '{ ${summon[Liftable[H]].toExpr(tup.head)} *: ${summon[Liftable[T]].toExpr(tup.tail)} } - // '{ ${tup.head.toExpr} *: ${tup.tail.toExpr} } // TODO figure out why this fails during CI documentation + // '{ ${Expr(tup.head)} *: ${Expr(tup.tail)} } // TODO figure out why this fails during CI documentation } given Liftable[BigInt] = new Liftable[BigInt] { def toExpr(x: BigInt): (given QuoteContext) => Expr[BigInt] = - '{ BigInt(${x.toByteArray.toExpr}) } + '{ BigInt(${Expr(x.toByteArray)}) } } /** Lift a BigDecimal using the default MathContext */ given Liftable[BigDecimal] = new Liftable[BigDecimal] { def toExpr(x: BigDecimal): (given QuoteContext) => Expr[BigDecimal] = - '{ BigDecimal(${x.toString.toExpr}) } + '{ BigDecimal(${Expr(x.toString)}) } } } diff --git a/library/src-bootstrapped/scala/quoted/package.scala b/library/src-bootstrapped/scala/quoted/package.scala index 01c410602039..720fbdb59ebe 100644 --- a/library/src-bootstrapped/scala/quoted/package.scala +++ b/library/src-bootstrapped/scala/quoted/package.scala @@ -3,6 +3,7 @@ package scala package object quoted { implicit object ExprOps { - def (x: T) toExpr[T: Liftable](given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) + @deprecated("Use scala.quoted.Expr.apply instead", "0.19.0") + def (x: T) toExpr[T: Liftable](given QuoteContext): Expr[T] = Expr(x) } } diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 6290df5309bd..75a38b7e389f 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -65,6 +65,9 @@ package quoted { Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]] } + /** Lift a value into an expression containing the construction of that value */ + def apply[T: Liftable](x: T)(given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) + /** Lifts this sequence of expressions into an expression of a sequence * * Transforms a sequence of expression diff --git a/library/src/scala/quoted/autolift.scala b/library/src/scala/quoted/autolift.scala index 8edb430be6ca..7d95cbcb6a87 100644 --- a/library/src/scala/quoted/autolift.scala +++ b/library/src/scala/quoted/autolift.scala @@ -3,5 +3,5 @@ package scala.quoted /** Enable implicit conversion from a term of type `T` to an expression of type `Expr[T]` */ object autolift { /** Implicit conversion from a term of type `T` to an expression of type `Expr[T]` */ - given autoToExpr[T](given Liftable[T], QuoteContext): Conversion[T, Expr[T]] = _.toExpr + given autoToExpr[T](given Liftable[T], QuoteContext): Conversion[T, Expr[T]] = Expr(_) } diff --git a/tests/disabled/pos/quote-whitebox/Macro_1.scala b/tests/disabled/pos/quote-whitebox/Macro_1.scala index 2f21ccdabc21..7f15fc13ae93 100644 --- a/tests/disabled/pos/quote-whitebox/Macro_1.scala +++ b/tests/disabled/pos/quote-whitebox/Macro_1.scala @@ -5,6 +5,6 @@ object Macro { inline def charOrString(inline str: String) <: Char | String = ${ impl(str) } - def impl(str: String) = if (str.length == 1) str.charAt(0).toExpr else str.toExpr + def impl(str: String) = if (str.length == 1) Expr(str.charAt(0)) else Expr(str) } diff --git a/tests/neg/GenericNumLits/Even_1.scala b/tests/neg-macros/GenericNumLits/Even_1.scala similarity index 96% rename from tests/neg/GenericNumLits/Even_1.scala rename to tests/neg-macros/GenericNumLits/Even_1.scala index 6c747aa60b57..978ae5f86e5a 100644 --- a/tests/neg/GenericNumLits/Even_1.scala +++ b/tests/neg-macros/GenericNumLits/Even_1.scala @@ -20,7 +20,7 @@ object Even { ctx.error(ex.getMessage) Even(0) } - '{Even(${ev.n.toExpr})} + '{Even(${Expr(ev.n)})} case _ => '{evenFromDigits($digits)} } diff --git a/tests/neg/GenericNumLits/Test_2.scala b/tests/neg-macros/GenericNumLits/Test_2.scala similarity index 100% rename from tests/neg/GenericNumLits/Test_2.scala rename to tests/neg-macros/GenericNumLits/Test_2.scala diff --git a/tests/neg-macros/inline-case-objects/Macro_1.scala b/tests/neg-macros/inline-case-objects/Macro_1.scala index 2527e4704494..45f591864f1f 100644 --- a/tests/neg-macros/inline-case-objects/Macro_1.scala +++ b/tests/neg-macros/inline-case-objects/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macros { - def impl(foo: Any)(given QuoteContext): Expr[String] = foo.getClass.getCanonicalName.toExpr + def impl(foo: Any)(given QuoteContext): Expr[String] = Expr(foo.getClass.getCanonicalName) } class Bar { diff --git a/tests/neg-macros/inline-option/Macro_1.scala b/tests/neg-macros/inline-option/Macro_1.scala index d13852b1a373..0eaa64d92f02 100644 --- a/tests/neg-macros/inline-option/Macro_1.scala +++ b/tests/neg-macros/inline-option/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macro { def impl(opt: Option[Int])(given QuoteContext): Expr[Int] = opt match { - case Some(i) => i.toExpr + case Some(i) => Expr(i) case None => '{-1} } } \ No newline at end of file diff --git a/tests/neg-macros/quote-macro-complex-arg-0.scala b/tests/neg-macros/quote-macro-complex-arg-0.scala index 6eb54e77d0e8..244e58119b13 100644 --- a/tests/neg-macros/quote-macro-complex-arg-0.scala +++ b/tests/neg-macros/quote-macro-complex-arg-0.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Macros { 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 - def bar(x: Int, y: Expr[Int])(given QuoteContext): Expr[Int] = '{ ${x.toExpr} + $y } + def bar(x: Int, y: Expr[Int])(given QuoteContext): Expr[Int] = '{ ${Expr(x)} + $y } } diff --git a/tests/neg-with-compiler/GenericNumLits/Even_1.scala b/tests/neg-with-compiler/GenericNumLits/Even_1.scala index 6c747aa60b57..978ae5f86e5a 100644 --- a/tests/neg-with-compiler/GenericNumLits/Even_1.scala +++ b/tests/neg-with-compiler/GenericNumLits/Even_1.scala @@ -20,7 +20,7 @@ object Even { ctx.error(ex.getMessage) Even(0) } - '{Even(${ev.n.toExpr})} + '{Even(${Expr(ev.n)})} case _ => '{evenFromDigits($digits)} } diff --git a/tests/neg/BigFloat/BigFloat_1.scala b/tests/neg/BigFloat/BigFloat_1.scala index e08102cc8b0c..0ef14e84c20d 100644 --- a/tests/neg/BigFloat/BigFloat_1.scala +++ b/tests/neg/BigFloat/BigFloat_1.scala @@ -35,7 +35,7 @@ object BigFloat extends App { case Const(ds) => try { val BigFloat(m, e) = apply(ds) - '{BigFloat(${m.toExpr}, ${e.toExpr})} + '{BigFloat(${Expr(m)}, ${Expr(e)})} } catch { case ex: FromDigits.FromDigitsException => @@ -60,7 +60,7 @@ object BigFloat extends App { given Liftable[BigInt] { def toExpr(x: BigInt) = - '{BigInt(${x.toString.toExpr})} + '{BigInt(${Expr(x.toString)})} } } diff --git a/tests/pending/pos/i4987.scala b/tests/pending/pos/i4987.scala index e251c4091697..26eda253d3f4 100644 --- a/tests/pending/pos/i4987.scala +++ b/tests/pending/pos/i4987.scala @@ -12,7 +12,6 @@ object Foo { implicit def NilIsLiftable: Liftable[Nil.type] = ??? - Nil.toExpr(NilIsLiftable) - (Nil.toExpr: Expr[Nil.type]) - Nil.toExpr + Expr(Nil)(given NilIsLiftable) + Expr(Nil) } \ No newline at end of file diff --git a/tests/pos-macros/quote-whitebox-2/Macro_1.scala b/tests/pos-macros/quote-whitebox-2/Macro_1.scala index 2f5864d6ca9f..a09a3c37707f 100644 --- a/tests/pos-macros/quote-whitebox-2/Macro_1.scala +++ b/tests/pos-macros/quote-whitebox-2/Macro_1.scala @@ -5,6 +5,6 @@ object Macro { inline def charOrString(inline str: String) <: Any = ${ impl(str) } - def impl(str: String)(given QuoteContext) = if (str.length == 1) str.charAt(0).toExpr else str.toExpr + def impl(str: String)(given QuoteContext) = if (str.length == 1) Expr(str.charAt(0)) else Expr(str) } diff --git a/tests/pos/i5547.scala b/tests/pos/i5547.scala index 86c9ade77232..26f1bad2a25c 100644 --- a/tests/pos/i5547.scala +++ b/tests/pos/i5547.scala @@ -5,7 +5,7 @@ object scalatest { ${assertImpl('condition, '{""})} inline def assert2(condition: => Boolean): Unit = - ${ assertImpl('condition, "".toExpr) } + ${ assertImpl('condition, Expr("")) } def assertImpl(condition: Expr[Boolean], clue: Expr[Any])(given QuoteContext): Expr[Unit] = '{} diff --git a/tests/pos/i6214.scala b/tests/pos/i6214.scala index dc48a301bdcd..736eabc8c28b 100644 --- a/tests/pos/i6214.scala +++ b/tests/pos/i6214.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Test { def res(x: quoted.Expr[Int])(given QuoteContext): quoted.Expr[Int] = x match { case '{ val a: Int = $y; 1} => y // owner of `y` is `res` - case _ => '{ val b: Int = ${val c = 2; c.toExpr}; 1} // owner of `c` is `b`, but that seems to be OK + case _ => '{ val b: Int = ${val c = 2; Expr(c)}; 1} // owner of `c` is `b`, but that seems to be OK } } \ No newline at end of file diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala index 248dfbbd5bbd..ef7a134cbae6 100644 --- a/tests/pos/quote-lift.scala +++ b/tests/pos/quote-lift.scala @@ -10,7 +10,7 @@ object Test { '{ ${summon[Liftable[Int]].toExpr(1)} } - '{ ${1.toExpr} } + '{ ${Expr(1)} } } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index d431911bf51f..2f74bb7f86ce 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -21,20 +21,20 @@ def test(given QuoteContext) = { implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { def toExpr(xs: List[T]) = xs match { - case x :: xs1 => '{ ${ implicitly[Liftable[T]].toExpr(x) } :: ${ toExpr(xs1) } } + case x :: xs1 => '{ ${ Expr(x) } :: ${ toExpr(xs1) } } case Nil => '{Nil: List[T]} } } - true.toExpr - 1.toExpr - 'a'.toExpr - 1.toExpr - 1.toExpr - 1L.toExpr - 1.0f.toExpr - 1.0.toExpr - "abc".toExpr + Expr(true) + Expr(1) + Expr('a') + Expr(1) + Expr(1) + Expr(1L) + Expr(1.0f) + Expr(1.0) + Expr("abc") - val xs: Expr[List[Int]] = (1 :: 2 :: 3 :: Nil).toExpr + val xs: Expr[List[Int]] = Expr(1 :: 2 :: 3 :: Nil) } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index 9d2acdd1a741..3610d120bc10 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -10,9 +10,9 @@ object Foo { import qctx.tasty._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsClassDefSymbol(sym) => sym.tree.showExtractors.toExpr - case IsDefDefSymbol(sym) => sym.tree.showExtractors.toExpr - case IsValDefSymbol(sym) => sym.tree.showExtractors.toExpr + case IsClassDefSymbol(sym) => Expr(sym.tree.showExtractors) + case IsDefDefSymbol(sym) => Expr(sym.tree.showExtractors) + case IsValDefSymbol(sym) => Expr(sym.tree.showExtractors) case _ => '{"NO DEFINTION"} } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 91e983046dfc..6787b6aeaff8 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -9,9 +9,9 @@ object Foo { import qctx.tasty._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsClassDefSymbol(sym) => sym.tree.showExtractors.toExpr - case IsDefDefSymbol(sym) => sym.tree.showExtractors.toExpr - case IsValDefSymbol(sym) => sym.tree.showExtractors.toExpr + case IsClassDefSymbol(sym) => Expr(sym.tree.showExtractors) + case IsDefDefSymbol(sym) => Expr(sym.tree.showExtractors) + case IsValDefSymbol(sym) => Expr(sym.tree.showExtractors) case _ => '{"NO DEFINTION"} } diff --git a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala index e06ce4295872..21ddb95c16ab 100644 --- a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala @@ -9,7 +9,7 @@ object TypeToolbox { private def tpEqImpl[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ val res = a.unseal.tpe =:= b.unseal.tpe - res.toExpr + Expr(res) } /** is `tp1` a subtype of `tp2` */ @@ -17,7 +17,7 @@ object TypeToolbox { private def tpLEqImpl[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ val res = a.unseal.tpe <:< b.unseal.tpe - res.toExpr + Expr(res) } /** type associated with the tree */ @@ -25,7 +25,7 @@ object TypeToolbox { private def typeOfImpl(a: Expr[_], expected: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ val res = a.unseal.tpe =:= expected.unseal.tpe - res.toExpr + Expr(res) } /** does the type refer to a case class? */ @@ -36,7 +36,7 @@ object TypeToolbox { case IsClassDefSymbol(sym) => sym.flags.is(Flags.Case) case _ => false } - res.toExpr + Expr(res) } /** val fields of a case class Type -- only the ones declared in primary constructor */ @@ -44,59 +44,59 @@ object TypeToolbox { private def caseFieldsImpl(tp: Type[_])(given qctx: QuoteContext): Expr[List[String]] = { import qctx.tasty._ val fields = tp.unseal.symbol.asClassDef.caseFields.map(_.name) - fields.toExpr + Expr(fields) } inline def fieldIn[T](inline mem: String): String = ${fieldInImpl('[T], mem)} private def fieldInImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ val field = t.unseal.symbol.asClassDef.field(mem) - field.map(_.name).getOrElse("").toExpr + Expr(field.map(_.name).getOrElse("")) } inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl('[T])} private def fieldsInImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty._ val fields = t.unseal.symbol.asClassDef.fields - fields.map(_.name).toList.toExpr + Expr(fields.map(_.name).toList) } inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl('[T], mem)} private def methodInImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty._ - t.unseal.symbol.asClassDef.classMethod(mem).map(_.name).toExpr + Expr(t.unseal.symbol.asClassDef.classMethod(mem).map(_.name)) } inline def methodsIn[T]: Seq[String] = ${methodsInImpl('[T])} private def methodsInImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty._ - t.unseal.symbol.asClassDef.classMethods.map(_.name).toExpr + Expr(t.unseal.symbol.asClassDef.classMethods.map(_.name)) } inline def method[T](inline mem: String): Seq[String] = ${methodImpl('[T], mem)} private def methodImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty._ - t.unseal.symbol.asClassDef.method(mem).map(_.name).toExpr + Expr(t.unseal.symbol.asClassDef.method(mem).map(_.name)) } inline def methods[T]: Seq[String] = ${methodsImpl('[T])} private def methodsImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty._ - t.unseal.symbol.asClassDef.methods.map(_.name).toExpr + Expr(t.unseal.symbol.asClassDef.methods.map(_.name)) } inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} private def typeTagImpl(tp: Type[_])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ val res = tp.unseal.tpe.show - res.toExpr + Expr(res) } inline def companion[T1, T2]: Boolean = ${companionImpl('[T1], '[T2])} private def companionImpl(t1: Type[_], t2: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ val res = t1.unseal.symbol.asClassDef.companionModule.contains(t2.unseal.symbol) - res.toExpr + Expr(res) } inline def companionName[T1]: String = ${companionNameImpl('[T1])} @@ -107,7 +107,7 @@ object TypeToolbox { case IsValDefSymbol(sym) => sym.companionClass case _ => None } - companionClassOpt.map(_.fullName).getOrElse("").toExpr + Expr(companionClassOpt.map(_.fullName).getOrElse("")) } } diff --git a/tests/run-macros/i5629/Macro_1.scala b/tests/run-macros/i5629/Macro_1.scala index 9ccd46119905..cf7a6306f336 100644 --- a/tests/run-macros/i5629/Macro_1.scala +++ b/tests/run-macros/i5629/Macro_1.scala @@ -14,6 +14,6 @@ object Macros { def thisLineNumberImpl(given qctx: QuoteContext): Expr[Int] = { import qctx.tasty._ - rootPosition.startLine.toExpr + Expr(rootPosition.startLine) } } diff --git a/tests/run-macros/i6765-b/Macro_1.scala b/tests/run-macros/i6765-b/Macro_1.scala index 33dd62117c1e..cbe5a11d1b1b 100644 --- a/tests/run-macros/i6765-b/Macro_1.scala +++ b/tests/run-macros/i6765-b/Macro_1.scala @@ -5,5 +5,5 @@ inline def foo = ${fooImpl} def fooImpl(given qctx: QuoteContext) = { val res = Expr.ofList(List('{"One"})) - res.show.toExpr + Expr(res.show) } diff --git a/tests/run-macros/i6765-c/Macro_1.scala b/tests/run-macros/i6765-c/Macro_1.scala index fb7d3d7cb5d1..3d521e7788c2 100644 --- a/tests/run-macros/i6765-c/Macro_1.scala +++ b/tests/run-macros/i6765-c/Macro_1.scala @@ -4,6 +4,6 @@ import scala.quoted.given inline def foo(inline n: Int) = ${fooImpl(n)} def fooImpl(n: Int)(given qctx: QuoteContext) = { - val res = Expr.ofList(List.tabulate(n)(i => ("#" + i).toExpr)) - '{ ${res.show.toExpr} + "\n" + $res.toString + "\n" } + val res = Expr.ofList(List.tabulate(n)(i => Expr("#" + i))) + '{ ${Expr(res.show)} + "\n" + $res.toString + "\n" } } diff --git a/tests/run-macros/i6765/Macro_1.scala b/tests/run-macros/i6765/Macro_1.scala index 877adfcdc319..fcce12c14909 100644 --- a/tests/run-macros/i6765/Macro_1.scala +++ b/tests/run-macros/i6765/Macro_1.scala @@ -6,5 +6,5 @@ inline def foo = ${fooImpl} def fooImpl(given qctx: QuoteContext) = { import qctx.tasty._ val res = Expr.ofList(List('{"One"})) - res.show.toExpr + Expr(res.show) } diff --git a/tests/run-macros/inline-case-objects/Macro_1.scala b/tests/run-macros/inline-case-objects/Macro_1.scala index 39f5ec3570b5..562e6a2aad34 100644 --- a/tests/run-macros/inline-case-objects/Macro_1.scala +++ b/tests/run-macros/inline-case-objects/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macros { - def impl(foo: Any)(given QuoteContext): Expr[String] = foo.getClass.getCanonicalName.toExpr + def impl(foo: Any)(given QuoteContext): Expr[String] = Expr(foo.getClass.getCanonicalName) } case object Bar { diff --git a/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala b/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala index e251a5bdf690..d930d6f6915e 100644 --- a/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala @@ -14,11 +14,11 @@ trait E[T] { } case class I(n: Int) extends E[Int] { - def lift(given QuoteContext): Expr[Int] = n.toExpr + def lift(given QuoteContext): Expr[Int] = Expr(n) } case class D(n: Double) extends E[Double] { - def lift(given QuoteContext): Expr[Double] = n.toExpr + def lift(given QuoteContext): Expr[Double] = Expr(n) } case class Plus[T](x: E[T], y: E[T])(implicit op: Plus2[T]) extends E[T] { diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index a21bec5c0f02..876a8334f7a1 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -21,9 +21,9 @@ object Macros { } '{ - println("Scrutinee: " + ${a.unseal.show.toExpr}) - println("Pattern: " + ${b.unseal.show.toExpr}) - println("Result: " + ${res.toString.toExpr}) + println("Scrutinee: " + ${Expr(a.unseal.show)}) + println("Pattern: " + ${Expr(b.unseal.show)}) + println("Result: " + ${Expr(res.toString)}) println() } } diff --git a/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala b/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala index 54797158ab77..280ded9f7554 100644 --- a/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator-2/quoted_1.scala @@ -11,7 +11,7 @@ object Macros { case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args1)) => val strParts = parts.map { case Const(str) => str.reverse } val strArgs = args1.map { case Const(str) => str } - StringContext(strParts: _*).s(strArgs: _*).toExpr + Expr(StringContext(strParts: _*).s(strArgs: _*)) case _ => ??? } diff --git a/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala b/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala index 9db05e58b53f..63f6fda3a37d 100644 --- a/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator-3/quoted_1.scala @@ -10,7 +10,7 @@ object Macros { self match { case '{ StringContext(${ConstSeq(parts)}: _*) } => val upprerParts: List[String] = parts.toList.map(_.toUpperCase) - val upprerPartsExpr: Expr[List[String]] = Expr.ofList(upprerParts.map(_.toExpr)) + val upprerPartsExpr: Expr[List[String]] = Expr.ofList(upprerParts.map(Expr(_))) '{ StringContext($upprerPartsExpr: _*).s($args: _*) } case _ => '{ diff --git a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala index 1d657398f5b9..99a9598d912e 100644 --- a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala @@ -11,7 +11,7 @@ object Macros { def lift(e: Expr[DSL]): Expr[T] = e match { case '{ LitDSL(${ Const(c) }) } => - '{ $sym.value(${c.toExpr}) } + '{ $sym.value(${Expr(c)}) } case '{ ($x: DSL) + ($y: DSL) } => '{ $sym.plus(${lift(x)}, ${lift(y)}) } diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index 2121f36edbe8..e654da688779 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -69,7 +69,7 @@ trait Symantics[Num] { } object StringNum extends Symantics[String] { - def value(x: Int)(given QuoteContext): Expr[String] = x.toString.toExpr + def value(x: Int)(given QuoteContext): Expr[String] = Expr(x.toString) def plus(x: Expr[String], y: Expr[String])(given QuoteContext): Expr[String] = '{ s"${$x} + ${$y}" } // '{ x + " + " + y } def times(x: Expr[String], y: Expr[String])(given QuoteContext): Expr[String] = '{ s"${$x} * ${$y}" } def app(f: Expr[String => String], x: Expr[String])(given QuoteContext): Expr[String] = f(x) // functions are beta reduced @@ -77,7 +77,7 @@ object StringNum extends Symantics[String] { } object ComputeNum extends Symantics[Int] { - def value(x: Int)(given QuoteContext): Expr[Int] = x.toExpr + def value(x: Int)(given QuoteContext): Expr[Int] = Expr(x) def plus(x: Expr[Int], y: Expr[Int])(given QuoteContext): Expr[Int] = '{ $x + $y } def times(x: Expr[Int], y: Expr[Int])(given QuoteContext): Expr[Int] = '{ $x * $y } def app(f: Expr[Int => Int], x: Expr[Int])(given QuoteContext): Expr[Int] = '{ $f($x) } @@ -85,7 +85,7 @@ object ComputeNum extends Symantics[Int] { } object ASTNum extends Symantics[ASTNum] { - def value(x: Int)(given QuoteContext): Expr[ASTNum] = '{ LitAST(${x.toExpr}) } + def value(x: Int)(given QuoteContext): Expr[ASTNum] = '{ LitAST(${Expr(x)}) } def plus(x: Expr[ASTNum], y: Expr[ASTNum])(given QuoteContext): Expr[ASTNum] = '{ PlusAST($x, $y) } def times(x: Expr[ASTNum], y: Expr[ASTNum])(given QuoteContext): Expr[ASTNum] = '{ TimesAST($x, $y) } def app(f: Expr[ASTNum => ASTNum], x: Expr[ASTNum])(given QuoteContext): Expr[ASTNum] = '{ AppAST($f, $x) } diff --git a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala index e8b75b318d9d..0600067111ff 100644 --- a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala @@ -22,8 +22,8 @@ object Macros { } def lift[T: Type](e: Expr[T])(given env: Env): Expr[R[T]] = ((e: Expr[Any]) match { - case Const(e: Int) => '{ $sym.int(${e.toExpr}).asInstanceOf[R[T]] } - case Const(e: Boolean) => '{ $sym.bool(${e.toExpr}).asInstanceOf[R[T]] } + case Const(e: Int) => '{ $sym.int(${Expr(e)}).asInstanceOf[R[T]] } + case Const(e: Boolean) => '{ $sym.bool(${Expr(e)}).asInstanceOf[R[T]] } case '{ ($x: Int) + ($y: Int) } => '{ $sym.add(${lift(x)}, ${lift(y)}).asInstanceOf[R[T]] } diff --git a/tests/run-macros/quote-type-matcher-2/quoted_1.scala b/tests/run-macros/quote-type-matcher-2/quoted_1.scala index 52ba4dc876b2..179d4fdaed65 100644 --- a/tests/run-macros/quote-type-matcher-2/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher-2/quoted_1.scala @@ -12,7 +12,7 @@ object Macros { case '[Function1[$t, $u]] => s"%${lift(t)} => ${lift(u)}%" case _ => tp.show } - lift(tp).toExpr + Expr(lift(tp)) } } diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index 1ece7b3dc723..9188e43eeab0 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -19,9 +19,9 @@ object Macros { } '{ - println("Scrutinee: " + ${a.unseal.show.toExpr}) - println("Pattern: " + ${b.unseal.show.toExpr}) - println("Result: " + ${res.toString.toExpr}) + println("Scrutinee: " + ${Expr(a.unseal.show)}) + println("Pattern: " + ${Expr(b.unseal.show)}) + println("Result: " + ${Expr(res.toString)}) println() } } diff --git a/tests/run-macros/reflect-inline/assert_1.scala b/tests/run-macros/reflect-inline/assert_1.scala index 4eb901ed9953..693a185eee32 100644 --- a/tests/run-macros/reflect-inline/assert_1.scala +++ b/tests/run-macros/reflect-inline/assert_1.scala @@ -5,12 +5,12 @@ object api { ${ stripImpl(x) } private def stripImpl(x: String)(given qctx: QuoteContext): Expr[String] = - x.stripMargin.toExpr + Expr(x.stripMargin) inline def typeChecks(inline x: String): Boolean = ${ typeChecksImpl(scala.compiletime.testing.typeChecks(x)) } private def typeChecksImpl(b: Boolean)(given qctx: QuoteContext): Expr[Boolean] = { - if (b) true.toExpr else false.toExpr + if (b) Expr(true) else Expr(false) } } diff --git a/tests/run-macros/reflect-isFunctionType/macro_1.scala b/tests/run-macros/reflect-isFunctionType/macro_1.scala index 5a3528d3868e..dd42f983d8e7 100644 --- a/tests/run-macros/reflect-isFunctionType/macro_1.scala +++ b/tests/run-macros/reflect-isFunctionType/macro_1.scala @@ -5,7 +5,7 @@ inline def isFunctionType[T:Type]: Boolean = ${ isFunctionTypeImpl('[T]) } def isFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ - tp.unseal.tpe.isFunctionType.toExpr + Expr(tp.unseal.tpe.isFunctionType) } @@ -13,7 +13,7 @@ inline def isImplicitFunctionType[T:Type]: Boolean = ${ isImplicitFunctionTypeIm def isImplicitFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ - tp.unseal.tpe.isImplicitFunctionType.toExpr + Expr(tp.unseal.tpe.isImplicitFunctionType) } @@ -21,13 +21,13 @@ inline def isErasedFunctionType[T:Type]: Boolean = ${ isErasedFunctionTypeImpl(' def isErasedFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ - tp.unseal.tpe.isErasedFunctionType.toExpr + Expr(tp.unseal.tpe.isErasedFunctionType) } inline def isDependentFunctionType[T:Type]: Boolean = ${ isDependentFunctionTypeImpl('[T]) } def isDependentFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty._ - tp.unseal.tpe.isDependentFunctionType.toExpr + Expr(tp.unseal.tpe.isDependentFunctionType) } diff --git a/tests/run-macros/reflect-typeChecks/assert_1.scala b/tests/run-macros/reflect-typeChecks/assert_1.scala index 7515a2589865..13b0a25ae8a8 100644 --- a/tests/run-macros/reflect-typeChecks/assert_1.scala +++ b/tests/run-macros/reflect-typeChecks/assert_1.scala @@ -6,6 +6,6 @@ object scalatest { inline def assertNotCompile(inline code: String): Unit = ${ assertImpl(code, compiletime.testing.typeChecks(code), false) } def assertImpl(code: String, actual: Boolean, expect: Boolean)(given qctx: QuoteContext): Expr[Unit] = { - '{ assert(${expect.toExpr} == ${actual.toExpr}) } + '{ assert(${Expr(expect)} == ${Expr(actual)}) } } } diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index a474663316d6..24a8dfaf9efd 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -6,6 +6,6 @@ object Macros { def impl[T](x: quoted.Type[T])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ - x.unseal.tpe.dealias.show.toExpr + Expr(x.unseal.tpe.dealias.show) } } diff --git a/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala b/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala index 0c7b681783b5..fb10671b2add 100644 --- a/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala @@ -12,7 +12,7 @@ object Macros { val buff = new StringBuilder def stagedPrintln(x: Any): Unit = buff append java.util.Objects.toString(x) append "\n" - 3.toExpr match { case Const(n) => stagedPrintln(n) } + Expr(3) match { case Const(n) => stagedPrintln(n) } '{4} match { case Const(n) => stagedPrintln(n) } '{"abc"} match { case Const(n) => stagedPrintln(n) } '{null} match { case Const(n) => stagedPrintln(n) } diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index aa2c93bfb59c..4058ae2e045d 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -14,7 +14,7 @@ object Macros { val code = x.unseal.underlyingArgument.show '{ println(${posStr(qctx)(pos)}) - println(${code.toExpr}) + println(${Expr(code)}) } } @@ -24,13 +24,13 @@ object Macros { val code = x.unseal.show '{ println(${posStr(qctx)(pos)}) - println(${code.toExpr}) + println(${Expr(code)}) } } def posStr(qctx: QuoteContext)(pos: qctx.tasty.Position): Expr[String] = { given QuoteContext = qctx import qctx.tasty._ - s"${pos.sourceFile.jpath.getFileName.toString}:[${pos.start}..${pos.end}]".toExpr + Expr(s"${pos.sourceFile.jpath.getFileName.toString}:[${pos.start}..${pos.end}]") } } diff --git a/tests/run-macros/tasty-simplified/quoted_1.scala b/tests/run-macros/tasty-simplified/quoted_1.scala index 0bca76878788..b183b3226b0b 100644 --- a/tests/run-macros/tasty-simplified/quoted_1.scala +++ b/tests/run-macros/tasty-simplified/quoted_1.scala @@ -19,6 +19,6 @@ object Macros { } val tps = unpackTuple(typeOf[T]) - Expr.ofSeq(tps.map(_.show.toExpr)) + Expr.ofSeq(tps.map(x => Expr(x.show))) } } diff --git a/tests/run-macros/type-show/Macro_1.scala b/tests/run-macros/type-show/Macro_1.scala index 1308ec06128c..d60575543866 100644 --- a/tests/run-macros/type-show/Macro_1.scala +++ b/tests/run-macros/type-show/Macro_1.scala @@ -4,6 +4,6 @@ object TypeToolbox { inline def show[A]: String = ${ showImpl('[A]) } private def showImpl[A, B](a: Type[A])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ - a.show.toExpr + Expr(a.show) } } diff --git a/tests/run-staging/i3847-b.scala b/tests/run-staging/i3847-b.scala index f1d54581b0b3..43d75b08949f 100644 --- a/tests/run-staging/i3847-b.scala +++ b/tests/run-staging/i3847-b.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], qctx: QuoteContext): Liftable[Array[List[T]]] = { new Liftable[Array[List[T]]] { def toExpr(arr: Array[List[T]]) = '{ - new Array[List[$t]](${arr.length.toExpr}) + new Array[List[$t]](${Expr(arr.length)}) // TODO add elements } } @@ -18,7 +18,7 @@ object Test { def main(args: Array[String]): Unit = withQuoteContext { import Arrays._ implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int} - val arr: Expr[Array[List[Int]]] = Array[List[Int]](List(1, 2, 3)).toExpr + val arr: Expr[Array[List[Int]]] = Expr(Array[List[Int]](List(1, 2, 3))) println(arr.show) } } diff --git a/tests/run-staging/i3847.scala b/tests/run-staging/i3847.scala index d6f08ce029cb..2fe1d02d6690 100644 --- a/tests/run-staging/i3847.scala +++ b/tests/run-staging/i3847.scala @@ -6,7 +6,7 @@ object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = { new Liftable[Array[T]] { def toExpr(arr: Array[T]) = '{ - new Array[$t](${arr.length.toExpr})($ct) + new Array[$t](${Expr(arr.length)})($ct) // TODO add elements } } @@ -18,7 +18,7 @@ object Test { def main(args: Array[String]): Unit = withQuoteContext { import Arrays._ implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int} - val arr: Expr[Array[Int]] = Array[Int](1, 2, 3).toExpr + val arr: Expr[Array[Int]] = Expr(Array[Int](1, 2, 3)) println(arr.show) } } diff --git a/tests/run-staging/i3947.scala b/tests/run-staging/i3947.scala index 4137b1334c5c..4e65cdcfe2ae 100644 --- a/tests/run-staging/i3947.scala +++ b/tests/run-staging/i3947.scala @@ -7,7 +7,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947b.scala b/tests/run-staging/i3947b.scala index 9e98e3964e7d..68dcd0ea85da 100644 --- a/tests/run-staging/i3947b.scala +++ b/tests/run-staging/i3947b.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println() println(name.show) diff --git a/tests/run-staging/i3947b2.scala b/tests/run-staging/i3947b2.scala index 177087f29ca8..6d4254a5e097 100644 --- a/tests/run-staging/i3947b2.scala +++ b/tests/run-staging/i3947b2.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: (given QuoteContext) => java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println() println(name.show) diff --git a/tests/run-staging/i3947b3.scala b/tests/run-staging/i3947b3.scala index c369464ba5fb..92a2e89e0628 100644 --- a/tests/run-staging/i3947b3.scala +++ b/tests/run-staging/i3947b3.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947c.scala b/tests/run-staging/i3947c.scala index d655c982db5e..f63890177c43 100644 --- a/tests/run-staging/i3947c.scala +++ b/tests/run-staging/i3947c.scala @@ -7,7 +7,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947d.scala b/tests/run-staging/i3947d.scala index fbe2e3e50afe..3b44a5126b3f 100644 --- a/tests/run-staging/i3947d.scala +++ b/tests/run-staging/i3947d.scala @@ -6,7 +6,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947d2.scala b/tests/run-staging/i3947d2.scala index fbacac21be3f..cc9e2a3839de 100644 --- a/tests/run-staging/i3947d2.scala +++ b/tests/run-staging/i3947d2.scala @@ -7,7 +7,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947e.scala b/tests/run-staging/i3947e.scala index 75bb6cb765e6..def71f6b51e9 100644 --- a/tests/run-staging/i3947e.scala +++ b/tests/run-staging/i3947e.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947f.scala b/tests/run-staging/i3947f.scala index 9cdaa83b2346..048d6d296404 100644 --- a/tests/run-staging/i3947f.scala +++ b/tests/run-staging/i3947f.scala @@ -8,7 +8,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947g.scala b/tests/run-staging/i3947g.scala index 9b058ae74d35..89d1d32c5c9a 100644 --- a/tests/run-staging/i3947g.scala +++ b/tests/run-staging/i3947g.scala @@ -6,7 +6,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947i.scala b/tests/run-staging/i3947i.scala index d6246605caa4..698b91b8b21b 100644 --- a/tests/run-staging/i3947i.scala +++ b/tests/run-staging/i3947i.scala @@ -7,7 +7,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i3947j.scala b/tests/run-staging/i3947j.scala index 707078a524de..ea6dae78d9a3 100644 --- a/tests/run-staging/i3947j.scala +++ b/tests/run-staging/i3947j.scala @@ -7,7 +7,7 @@ object Test { def main(args: Array[String]): Unit = run { def test[T: Type](clazz: java.lang.Class[T]) = { - val lclazz = clazz.toExpr + val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) '{ println($name) } diff --git a/tests/run-staging/i4730.scala b/tests/run-staging/i4730.scala index 00e53805cf92..5c2d3c551388 100644 --- a/tests/run-staging/i4730.scala +++ b/tests/run-staging/i4730.scala @@ -6,7 +6,7 @@ object Test { def ret(given QuoteContext): Expr[Int => Int] = '{ (x: Int) => ${ val z = run('{x + 1}) // throws a RunScopeException - z.toExpr + Expr(z) } } def main(args: Array[String]): Unit = { diff --git a/tests/run-staging/i5161.scala b/tests/run-staging/i5161.scala index e87e3166c6f2..a9aa13d0463f 100644 --- a/tests/run-staging/i5161.scala +++ b/tests/run-staging/i5161.scala @@ -11,7 +11,7 @@ object Test { import Exp._ def evalTest(e: Exp)(given QuoteContext): Expr[Option[Int]] = e match { - case Int2(x) => '{ Some(${x.toExpr}) } + case Int2(x) => '{ Some(${Expr(x)}) } case Add(e1, e2) => '{ (${evalTest(e1)}, ${evalTest(e2)}) match { diff --git a/tests/run-staging/i6992/Macro_1.scala b/tests/run-staging/i6992/Macro_1.scala index dbeb964edc38..d5d2cd4cb0c7 100644 --- a/tests/run-staging/i6992/Macro_1.scala +++ b/tests/run-staging/i6992/Macro_1.scala @@ -14,7 +14,7 @@ object macros { import ctx.tasty._ try { body match { - case '{$x: Foo} => run(x).x.toExpr + case '{$x: Foo} => Expr(run(x).x) } } catch { case ex: scala.quoted.ScopeException => diff --git a/tests/run-staging/quote-lib.scala b/tests/run-staging/quote-lib.scala index 0268b9cb80ce..7fe391c50186 100644 --- a/tests/run-staging/quote-lib.scala +++ b/tests/run-staging/quote-lib.scala @@ -25,28 +25,28 @@ object Test { val t2: Expr[(Int, Int)] = (2, 3) val t3: Expr[(Int, Int, Int)] = (2, 3, 4) val t4: Expr[(Int, Int, Int, Int)] = (2, 3, 4, 5) - (1, 2, 3, 4).toExpr - (1, 2, 3, 4, 5).toExpr - (1, 2, 3, 4, 5, 6).toExpr - (1, 2, 3, 4, 5, 6, 7).toExpr - (1, 2, 3, 4, 5, 6, 7, 8).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).toExpr - (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).toExpr + Expr((1, 2, 3, 4)) + Expr((1, 2, 3, 4, 5)) + Expr((1, 2, 3, 4, 5, 6)) + Expr((1, 2, 3, 4, 5, 6, 7)) + Expr((1, 2, 3, 4, 5, 6, 7, 8)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)) + Expr((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)) val list: List[Int] = List(1, 2, 3) val liftedList: Expr[List[Int]] = list @@ -70,30 +70,30 @@ object Test { val liftedIArray: Expr[IArray[Int]] = iarray val iarray2: IArray[String] = IArray("a", "b", "c") - iarray2.toExpr - - IArray(false).toExpr - IArray(1: Byte).toExpr - IArray(1: Short).toExpr - IArray(1).toExpr - IArray(1L).toExpr - IArray(1.1f).toExpr - IArray(1.1d).toExpr - IArray('a').toExpr - IArray((1, 3)).toExpr + Expr(iarray2) + + Expr(IArray(false)) + Expr(IArray(1: Byte)) + Expr(IArray(1: Short)) + Expr(IArray(1)) + Expr(IArray(1L)) + Expr(IArray(1.1f)) + Expr(IArray(1.1d)) + Expr(IArray('a')) + Expr(IArray((1, 3))) val array: Array[Int] = Array(1, 2, 3) val liftedArray: Expr[Array[Int]] = array - Array(false).toExpr - Array(1: Byte).toExpr - Array(1: Short).toExpr - Array(1).toExpr - Array(1L).toExpr - Array(1.1f).toExpr - Array(1.1d).toExpr - Array('a').toExpr - Array((1, 3)).toExpr + Expr(Array(false)) + Expr(Array(1: Byte)) + Expr(Array(1: Short)) + Expr(Array(1)) + Expr(Array(1L)) + Expr(Array(1.1f)) + Expr(Array(1.1d)) + Expr(Array('a')) + Expr(Array((1, 3))) val some: Option[Int] = Some(2) val none: Option[Int] = Some(2) @@ -102,8 +102,8 @@ object Test { val left: Either[Int, Long] = Left(1) val right: Either[Int, Long] = Right(2L) - left.toExpr - right.toExpr + Expr(left) + Expr(right) println("quote lib ok") } diff --git a/tests/run-staging/quote-lift-BigDecimal.scala b/tests/run-staging/quote-lift-BigDecimal.scala index 485ef8e7457f..7f94418535ec 100644 --- a/tests/run-staging/quote-lift-BigDecimal.scala +++ b/tests/run-staging/quote-lift-BigDecimal.scala @@ -3,8 +3,8 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = println(run { - val a = BigDecimal(2.3).toExpr - val b = BigDecimal("1005849025843905834908593485984390583429058574925.95489543").toExpr + val a = Expr(BigDecimal(2.3)) + val b = Expr(BigDecimal("1005849025843905834908593485984390583429058574925.95489543")) '{ ($a, $b) } }) } diff --git a/tests/run-staging/quote-lift-BigInt.scala b/tests/run-staging/quote-lift-BigInt.scala index 8e765e103416..cb35d779cd97 100644 --- a/tests/run-staging/quote-lift-BigInt.scala +++ b/tests/run-staging/quote-lift-BigInt.scala @@ -3,8 +3,8 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = println(run { - val a = BigInt(2).toExpr - val b = BigInt("1005849025843905834908593485984390583429058574925").toExpr + val a = Expr(BigInt(2)) + val b = Expr(BigInt("1005849025843905834908593485984390583429058574925")) '{ ($a, $b) } }) } diff --git a/tests/run-staging/quote-macro-in-splice/quoted_2.scala b/tests/run-staging/quote-macro-in-splice/quoted_2.scala index 84ef7e90d1fc..263c0bebfcbc 100644 --- a/tests/run-staging/quote-macro-in-splice/quoted_2.scala +++ b/tests/run-staging/quote-macro-in-splice/quoted_2.scala @@ -11,7 +11,7 @@ object Test { // FIXME remove context when $ will provide one // Currently we would accidentally capture the one from withQuoteContext inline def a(z: Int): Int = ${ impl('z)(given QuoteContext.macroContext) } - val b = a(7).toExpr + val b = Expr(a(7)) '{ y + $b } } } diff --git a/tests/run-staging/shonan-hmm-simple.scala b/tests/run-staging/shonan-hmm-simple.scala index 80cd92382eed..4a7cabba65bd 100644 --- a/tests/run-staging/shonan-hmm-simple.scala +++ b/tests/run-staging/shonan-hmm-simple.scala @@ -144,8 +144,8 @@ object Test { def blasStaticIntExpr(given QuoteContext) = new Blas1(new RingIntExpr, new StaticVecOps) def resCode1(given QuoteContext) = blasStaticIntExpr.dot( - vec1.map(_.toExpr), - vec2.map(_.toExpr) + vec1.map(Expr(_)), + vec2.map(Expr(_)) ) println(withQuoteContext(resCode1.show)) println(run(resCode1)) diff --git a/tests/run-staging/shonan-hmm/Complex.scala b/tests/run-staging/shonan-hmm/Complex.scala index 6ae06487d703..1a884094bee7 100644 --- a/tests/run-staging/shonan-hmm/Complex.scala +++ b/tests/run-staging/shonan-hmm/Complex.scala @@ -5,7 +5,7 @@ case class Complex[T](re: T, im: T) object Complex { implicit def complexIsLiftable[T: Type: Liftable]: Liftable[Complex[T]] = new Liftable { - def toExpr(c: Complex[T]) = '{ Complex(${c.re.toExpr}, ${c.im.toExpr}) } + def toExpr(c: Complex[T]) = '{ Complex(${Expr(c.re)}, ${Expr(c.im)}) } } def of_complex_expr(x: Expr[Complex[Int]])(given QuoteContext): Complex[Expr[Int]] = Complex('{$x.re}, '{$x.im}) diff --git a/tests/run-staging/shonan-hmm/PV.scala b/tests/run-staging/shonan-hmm/PV.scala index 653b6f4538db..aaec80bcfbd4 100644 --- a/tests/run-staging/shonan-hmm/PV.scala +++ b/tests/run-staging/shonan-hmm/PV.scala @@ -9,7 +9,7 @@ case class Dyn[T](x: Expr[T]) extends PV[T] object Dyns { def dyn[T: Liftable](pv: PV[T])(given QuoteContext): Expr[T] = pv match { - case Sta(x) => x.toExpr + case Sta(x) => Expr(x) case Dyn(x) => x } def dyni(given QuoteContext): PV[Int] => Expr[Int] = dyn[Int] diff --git a/tests/run-staging/staged-tuples/StagedTuple.scala b/tests/run-staging/staged-tuples/StagedTuple.scala index 054b72ed950d..c18902f8a47c 100644 --- a/tests/run-staging/staged-tuples/StagedTuple.scala +++ b/tests/run-staging/staged-tuples/StagedTuple.scala @@ -26,7 +26,7 @@ object StagedTuple { case Some(4) => tup.as[Tuple4[Object, Object, Object, Object]].bind(t => '{Array($t._1, $t._2, $t._3, $t._4)}) case Some(n) if n <= MaxSpecialized => - '{to$Array($tup, ${ n.toExpr })} + '{to$Array($tup, ${ Expr(n) })} case Some(n) => '{ ${tup.as[TupleXXL]}.toArray } case None => @@ -72,7 +72,7 @@ object StagedTuple { val res = if (!specialize) '{dynamicSize($tup)} else size match { - case Some(n) => n.toExpr + case Some(n) => Expr(n) case None => '{dynamicSize($tup)} } res.as[Res] @@ -133,7 +133,7 @@ object StagedTuple { def fallbackApply(): Expr[Elem[Tup, N]] = nValue match { case Some(n) => qctx.error("index out of bounds: " + n, tup) - '{ throw new IndexOutOfBoundsException(${n.toString.toExpr}) } + '{ throw new IndexOutOfBoundsException(${Expr(n.toString)}) } case None => '{dynamicApply($tup, $n)} } val res = size match { @@ -170,13 +170,13 @@ object StagedTuple { case Some(s) if s > 4 && s <= MaxSpecialized => val t = tup.as[Product] nValue match { - case Some(n) if n >= 0 && n < s => '{$t.productElement(${ n.toExpr })} + case Some(n) if n >= 0 && n < s => '{$t.productElement(${ Expr(n) })} case _ => fallbackApply() } case Some(s) if s > MaxSpecialized => val t = tup.as[TupleXXL] nValue match { - case Some(n) if n >= 0 && n < s => '{$t.elems(${ n.toExpr })} + case Some(n) if n >= 0 && n < s => '{$t.elems(${ Expr(n) })} case _ => fallbackApply() } case _ => fallbackApply() diff --git a/tests/run-with-compiler/BigFloat/BigFloat_1.scala b/tests/run-with-compiler/BigFloat/BigFloat_1.scala index e08102cc8b0c..0ef14e84c20d 100644 --- a/tests/run-with-compiler/BigFloat/BigFloat_1.scala +++ b/tests/run-with-compiler/BigFloat/BigFloat_1.scala @@ -35,7 +35,7 @@ object BigFloat extends App { case Const(ds) => try { val BigFloat(m, e) = apply(ds) - '{BigFloat(${m.toExpr}, ${e.toExpr})} + '{BigFloat(${Expr(m)}, ${Expr(e)})} } catch { case ex: FromDigits.FromDigitsException => @@ -60,7 +60,7 @@ object BigFloat extends App { given Liftable[BigInt] { def toExpr(x: BigInt) = - '{BigInt(${x.toString.toExpr})} + '{BigInt(${Expr(x.toString)})} } } diff --git a/tests/run-with-compiler/i6201/macro_1.scala b/tests/run-with-compiler/i6201/macro_1.scala index a45c913a0ce7..9343f9ebb361 100644 --- a/tests/run-with-compiler/i6201/macro_1.scala +++ b/tests/run-with-compiler/i6201/macro_1.scala @@ -4,11 +4,11 @@ inline def (inline x: String) strip: String = ${ stripImpl(x) } def stripImpl(x: String)(given qctx: QuoteContext): Expr[String] = - x.stripMargin.toExpr + Expr(x.stripMargin) inline def isHello(inline x: String): Boolean = ${ isHelloImpl(x) } def isHelloImpl(x: String)(given qctx: QuoteContext): Expr[Boolean] = - if (x == "hello") true.toExpr else false.toExpr + if (x == "hello") Expr(true) else Expr(false) diff --git a/tests/run-with-compiler/i6270/Macro_1.scala b/tests/run-with-compiler/i6270/Macro_1.scala index 9d425d8342d1..ad8e094e6e59 100644 --- a/tests/run-with-compiler/i6270/Macro_1.scala +++ b/tests/run-with-compiler/i6270/Macro_1.scala @@ -7,7 +7,7 @@ object api { private def reflImpl(x: Expr[String])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ - x.show.toExpr + Expr(x.show) } inline def (x: => String) reflectColor : String = @@ -15,6 +15,6 @@ object api { private def reflImplColor(x: Expr[String])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty._ - x.show(ANSI).toExpr + Expr(x.show(ANSI)) } } diff --git a/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala b/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala index 261f258bd297..33bd0e98af57 100644 --- a/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala +++ b/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala @@ -6,6 +6,6 @@ object api { private def reflImpl[T](x: Expr[T])(implicit qctx: QuoteContext): Expr[String] = { import qctx.tasty._ - x.unseal.pos.sourceCode.toExpr + Expr(x.unseal.pos.sourceCode) } } From 456c8b3d907d62e092bee52bb71b8fab9090dd7b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 19 Sep 2019 16:24:21 +0200 Subject: [PATCH 2/2] Replace quoted `toExpr` with `Expr.apply` in community build --- community-build/community-projects/minitest | 2 +- community-build/community-projects/scalatest | 2 +- community-build/community-projects/shapeless | 2 +- community-build/community-projects/sourcecode | 2 +- community-build/community-projects/xml-interpolator | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/community-build/community-projects/minitest b/community-build/community-projects/minitest index eaddd4dde4b8..e3a3d85b9079 160000 --- a/community-build/community-projects/minitest +++ b/community-build/community-projects/minitest @@ -1 +1 @@ -Subproject commit eaddd4dde4b8a84ddf62a20a781b939a135b3ea1 +Subproject commit e3a3d85b9079cb1085a059ad75a449a54aeaa963 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 8320e9c2edae..6a53948f8ad7 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 8320e9c2edae3b91a9c31a967fce404a2b141b34 +Subproject commit 6a53948f8ad733896387fceec860cc6a04e068d8 diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index 7b8be09378c4..876d630a65be 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit 7b8be09378c41da8839bb35f66f4a6b308508129 +Subproject commit 876d630a65be2746d6f4b84a869ed0a6bc2828d5 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index b23462bbaf37..380cdad97e5a 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit b23462bbaf3781e27fd54970a76b265cb2ae7e71 +Subproject commit 380cdad97e5ac27f79a8e33b3edd86657833b5a2 diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index e1db5ac1e9ad..ddbda123addf 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit e1db5ac1e9ad24dbe66084f570a49768802b599e +Subproject commit ddbda123addfcb255edab25e24fec51f16671fa9