diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 600252602d34..88ecf66d8cd5 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 600252602d346aaa7fb9402f70b2bfb4ec3ed9fa +Subproject commit 88ecf66d8cd56b3f280492a7e0088d7db7df693b diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 12c5b6eb5af6..22077993ae02 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 12c5b6eb5af64f25c3d34dba318d6145215805d5 +Subproject commit 22077993ae02467636f87b078713eba21ceb3dbd diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 2f4ceef39620..d5d1b9e003b3 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -251,8 +251,9 @@ The `toExpr` extension method is defined in package `quoted`: ```scala package quoted - delegate LiftingOps { - def (x: T) toExpr[T] given (ev: Liftable[T]): Expr[T] = ev.toExpr(x) + delegate ExprOps { + def (x: T) toExpr[T: Liftable] given QuoteContext: Expr[T] = the[Liftable[T]].toExpr(x) + ... } ``` The extension says that values of types implementing the `Liftable` type class can be @@ -269,7 +270,8 @@ knowing anything about the representation of `Expr` trees. For instance, here is a possible instance of `Liftable[Boolean]`: ```scala delegate for Liftable[Boolean] { - def toExpr(b: Boolean) = if (b) '{ true } else '{ false } + def toExpr(b: Boolean) given QuoteContext: Expr[Boolean] = + if (b) '{ true } else '{ false } } ``` Once we can lift bits, we can work our way up. For instance, here is a @@ -277,7 +279,7 @@ possible implementation of `Liftable[Int]` that does not use the underlying tree machinery: ```scala delegate for Liftable[Int] { - def toExpr(n: Int): Expr[Int] = n match { + def toExpr(n: Int) given QuoteContext: Expr[Int] = n match { case Int.MinValue => '{ Int.MinValue } case _ if n < 0 => '{ - ${ toExpr(-n) } } case 0 => '{ 0 } @@ -290,7 +292,7 @@ Since `Liftable` is a type class, its instances can be conditional. For example, a `List` is liftable if its element type is: ```scala delegate [T: Liftable] for Liftable[List[T]] { - def toExpr(xs: List[T]): Expr[List[T]] = xs match { + def toExpr(xs: List[T]) given QuoteContext: Expr[List[T]] = xs match { case head :: tail => '{ ${ toExpr(head) } :: ${ toExpr(tail) } } case Nil => '{ Nil: List[T] } } diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index cf9207f2d5a4..252429caf586 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -25,7 +25,6 @@ is used. ```scala import scala.quoted._ -import scala.tasty._ inline def natConst(x: => Int): Int = ${natConstImpl('{x})} diff --git a/library/src-3.x/scala/quoted/Liftable.scala b/library/src-3.x/scala/quoted/Liftable.scala index 9587a40a756b..63ab24dc1cf6 100644 --- a/library/src-3.x/scala/quoted/Liftable.scala +++ b/library/src-3.x/scala/quoted/Liftable.scala @@ -6,7 +6,7 @@ import scala.runtime.quoted.Unpickler.liftedExpr * without going through an explicit `'{...}` operation. */ abstract class Liftable[T] { - def toExpr(x: T): Expr[T] + def toExpr(x: T) given QuoteContext: Expr[T] } /** Some liftable base types. To be completed with at least all types @@ -27,7 +27,7 @@ object Liftable { implicit def ClassIsLiftable[T]: Liftable[Class[T]] = new PrimitiveLiftable private class PrimitiveLiftable[T] extends Liftable[T] { - override def toExpr(x: T): Expr[T] = liftedExpr(x) + override def toExpr(x: T) given QuoteContext: Expr[T] = liftedExpr(x) } } diff --git a/library/src-3.x/scala/quoted/package.scala b/library/src-3.x/scala/quoted/package.scala index b90ebb1cf090..5b59fca1cf4e 100644 --- a/library/src-3.x/scala/quoted/package.scala +++ b/library/src-3.x/scala/quoted/package.scala @@ -48,11 +48,11 @@ package object quoted { private object NoResult object autolift { - implicit def autoToExpr[T: Liftable](x: T): Expr[T] = x.toExpr + implicit def autoToExpr[T: Liftable](x: T) given QuoteContext: Expr[T] = x.toExpr } implicit object ExprOps { - def (x: T) toExpr[T] given Liftable[T]: Expr[T] = the[Liftable[T]].toExpr(x) + def (x: T) toExpr[T: Liftable] given QuoteContext: Expr[T] = the[Liftable[T]].toExpr(x) def (list: List[Expr[T]]) toExprOfList[T] given Type[T]: Expr[List[T]] = list match { case x :: xs => '{ $x :: ${xs.toExprOfList} } diff --git a/library/src-non-bootstrapped/dotty/internal/StringContextMacro.scala b/library/src-non-bootstrapped/dotty/internal/StringContextMacro.scala index 1a869f912c47..0f6a2bcf87dc 100644 --- a/library/src-non-bootstrapped/dotty/internal/StringContextMacro.scala +++ b/library/src-non-bootstrapped/dotty/internal/StringContextMacro.scala @@ -4,7 +4,6 @@ package dotty.internal import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection import reflect._ object StringContextMacro { diff --git a/semanticdb/src/dotty/semanticdb/Main.scala b/semanticdb/src/dotty/semanticdb/Main.scala index f9e444573dc2..b3a47d5becb8 100644 --- a/semanticdb/src/dotty/semanticdb/Main.scala +++ b/semanticdb/src/dotty/semanticdb/Main.scala @@ -1,6 +1,5 @@ package dotty.semanticdb -import scala.tasty.Reflection import scala.tasty.file._ import scala.NotImplementedError diff --git a/semanticdb/src/dotty/semanticdb/TastyScalaFileInferrer.scala b/semanticdb/src/dotty/semanticdb/TastyScalaFileInferrer.scala index d5e86bd8cd64..96ee81fedc1e 100644 --- a/semanticdb/src/dotty/semanticdb/TastyScalaFileInferrer.scala +++ b/semanticdb/src/dotty/semanticdb/TastyScalaFileInferrer.scala @@ -1,7 +1,5 @@ package dotty.semanticdb -import scala.tasty.Reflection - import scala.meta.internal.{semanticdb => s} import scala.tasty.Reflection import scala.tasty.file.TastyConsumer diff --git a/semanticdb/src/dotty/semanticdb/Utils.scala b/semanticdb/src/dotty/semanticdb/Utils.scala index 634e7ad9b80b..1484eda68e2c 100644 --- a/semanticdb/src/dotty/semanticdb/Utils.scala +++ b/semanticdb/src/dotty/semanticdb/Utils.scala @@ -1,7 +1,6 @@ package dotty.semanticdb -import scala.tasty.Reflection import scala.tasty.file._ import scala.collection.mutable.HashMap @@ -11,7 +10,6 @@ import java.nio.file._ import scala.meta.internal.{semanticdb => s} import scala.collection.JavaConverters._ import java.io.File -import scala.tasty.Reflection import scala.tasty.file.TastyConsumer import java.lang.reflect.InvocationTargetException diff --git a/semanticdb/test/dotty/semanticdb/Tests.scala b/semanticdb/test/dotty/semanticdb/Tests.scala index 480f38f5ea69..b412e45db6ec 100644 --- a/semanticdb/test/dotty/semanticdb/Tests.scala +++ b/semanticdb/test/dotty/semanticdb/Tests.scala @@ -1,6 +1,5 @@ package dotty.semanticdb -import scala.tasty.Reflection import scala.tasty.file._ import scala.collection.mutable.HashMap @@ -10,7 +9,6 @@ import java.nio.file._ import scala.meta.internal.{semanticdb => s} import scala.collection.JavaConverters._ import java.io.File -import scala.tasty.Reflection import scala.tasty.file.TastyConsumer import java.lang.reflect.InvocationTargetException diff --git a/tests/neg-macros/inline-case-objects/Macro_1.scala b/tests/neg-macros/inline-case-objects/Macro_1.scala index 4b636d5d4ec4..c52792b2a7c9 100644 --- a/tests/neg-macros/inline-case-objects/Macro_1.scala +++ b/tests/neg-macros/inline-case-objects/Macro_1.scala @@ -1,9 +1,8 @@ import scala.quoted._ -import scala.quoted.autolift._ object Macros { - def impl(foo: Any): Expr[String] = foo.getClass.getCanonicalName + def impl(foo: Any) given QuoteContext: Expr[String] = foo.getClass.getCanonicalName.toExpr } class Bar { diff --git a/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala b/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala index 5e5e71140fed..9bc5638ab34e 100644 --- a/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala @@ -6,29 +6,29 @@ object E { inline def eval[T](inline x: E[T]): T = ${ impl(x) } - def impl[T](x: E[T]): Expr[T] = x.lift + def impl[T](x: E[T]) given QuoteContext: Expr[T] = x.lift } trait E[T] { - def lift: Expr[T] + def lift given QuoteContext: Expr[T] } case class I(n: Int) extends E[Int] { - def lift: Expr[Int] = n + def lift given QuoteContext: Expr[Int] = n } case class Plus[T](x: E[T], y: E[T])(implicit op: Plus2[T]) extends E[T] { - def lift: Expr[T] = op(x.lift, y.lift) + def lift given QuoteContext: Expr[T] = op(x.lift, y.lift) } trait Op2[T] { - def apply(x: Expr[T], y: Expr[T]): Expr[T] + def apply(x: Expr[T], y: Expr[T]) given QuoteContext: Expr[T] } trait Plus2[T] extends Op2[T] object Plus2 { implicit case object IPlus extends Plus2[Int] { - def apply(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{$x + $y} + def apply(x: Expr[Int], y: Expr[Int]) given QuoteContext: Expr[Int] = '{$x + $y} } } diff --git a/tests/neg-macros/inline-option/Macro_1.scala b/tests/neg-macros/inline-option/Macro_1.scala index 525cfd71ab9d..4cdc75b23d01 100644 --- a/tests/neg-macros/inline-option/Macro_1.scala +++ b/tests/neg-macros/inline-option/Macro_1.scala @@ -1,10 +1,9 @@ import scala.quoted._ -import scala.quoted.autolift._ object Macro { - def impl(opt: Option[Int]): Expr[Int] = opt match { - case Some(i) => i + def impl(opt: Option[Int]) given QuoteContext: Expr[Int] = opt match { + case Some(i) => i.toExpr case None => '{-1} } } \ No newline at end of file diff --git a/tests/neg-macros/inline-tuples-1/Macro_1.scala b/tests/neg-macros/inline-tuples-1/Macro_1.scala index ad2439520403..4c2524d50e5a 100644 --- a/tests/neg-macros/inline-tuples-1/Macro_1.scala +++ b/tests/neg-macros/inline-tuples-1/Macro_1.scala @@ -3,26 +3,26 @@ import scala.quoted._ import scala.quoted.autolift._ object Macros { - def tup1(tup: Tuple1[Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup2(tup: Tuple2[Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup3(tup: Tuple3[Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup4(tup: Tuple4[Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup5(tup: Tuple5[Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup6(tup: Tuple6[Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup7(tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup8(tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup9(tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup10(tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup11(tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup12(tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup13(tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup14(tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup15(tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup16(tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup17(tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup18(tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup19(tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup20(tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup21(tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup22(tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup1(tup: Tuple1[Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup2(tup: Tuple2[Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup3(tup: Tuple3[Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup4(tup: Tuple4[Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup5(tup: Tuple5[Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup6(tup: Tuple6[Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup7(tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup8(tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup9(tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup10(tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup11(tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup12(tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup13(tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup14(tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup15(tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup16(tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup17(tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup18(tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup19(tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup20(tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup21(tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup22(tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum } diff --git a/tests/neg-macros/quote-interpolator-core-old.scala b/tests/neg-macros/quote-interpolator-core-old.scala index ddb2e6dc09f4..bc136668bf94 100644 --- a/tests/neg-macros/quote-interpolator-core-old.scala +++ b/tests/neg-macros/quote-interpolator-core-old.scala @@ -12,12 +12,12 @@ object FInterpolation { // ... } - private def liftSeq(args: Seq[Expr[Any]]): Expr[Seq[Any]] = args match { + private def liftSeq(args: Seq[Expr[Any]]) given QuoteContext: Expr[Seq[Any]] = args match { case x :: xs => '{ ($x) +: ${liftSeq(xs)} } case Nil => '{Seq(): Seq[Any]} } - def fInterpolation(sc: StringContext, args: Seq[Expr[Any]]): Expr[String] = { + def fInterpolation(sc: StringContext, args: Seq[Expr[Any]]) given QuoteContext: Expr[String] = { val str: Expr[String] = sc.parts.mkString("") val args1: Expr[Seq[Any]] = liftSeq(args) '{ $str.format($args1: _*) } diff --git a/tests/neg-macros/quote-macro-complex-arg-0.scala b/tests/neg-macros/quote-macro-complex-arg-0.scala index 90e202b21a31..b4ebf0abba1b 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]): Expr[Int] = '{ ${x.toExpr} + $y } + def bar(x: Int, y: Expr[Int]) given QuoteContext: Expr[Int] = '{ ${x.toExpr} + $y } } diff --git a/tests/neg-macros/splice-in-top-level-splice-1.scala b/tests/neg-macros/splice-in-top-level-splice-1.scala index 243cd43c5188..7fca05267ee4 100644 --- a/tests/neg-macros/splice-in-top-level-splice-1.scala +++ b/tests/neg-macros/splice-in-top-level-splice-1.scala @@ -4,5 +4,5 @@ import scala.quoted.autolift._ object Foo { inline def foo(): Int = ${bar(${x})} // error def x: Expr[Int] = '{1} - def bar(i: Int): Expr[Int] = i + def bar(i: Int) given QuoteContext: Expr[Int] = i } diff --git a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala index d91f253e9828..decce97d9722 100644 --- a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Asserts { implicit class Ops[T](left: T) { diff --git a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala index 3a79b8bf7214..bfc1341f3e93 100644 --- a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Asserts { implicit class Ops[T](left: T) { diff --git a/tests/neg-macros/tasty-macro-error/quoted_1.scala b/tests/neg-macros/tasty-macro-error/quoted_1.scala index d980cd1c0f06..b2dd17151304 100644 --- a/tests/neg-macros/tasty-macro-error/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-error/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Macros { inline def fun(x: Any): Unit = ${ impl('x) } diff --git a/tests/neg-macros/tasty-macro-positions/quoted_1.scala b/tests/neg-macros/tasty-macro-positions/quoted_1.scala index 9cfdf2930fc7..8f9b09787f31 100644 --- a/tests/neg-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-positions/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Macros { inline def fun(x: Any): Unit = ${ impl('x) } diff --git a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala index 6e7a985d0314..56d3155fefe9 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty.Reflection import scala.language.implicitConversions object Macro { diff --git a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala index 942429eff106..c0954fe704df 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty.Reflection import scala.language.implicitConversions object Macro { diff --git a/tests/neg-with-compiler/i5941/macro_1.scala b/tests/neg-with-compiler/i5941/macro_1.scala index 1e286b8de780..1562fd0e08e6 100644 --- a/tests/neg-with-compiler/i5941/macro_1.scala +++ b/tests/neg-with-compiler/i5941/macro_1.scala @@ -4,7 +4,6 @@ abstract class Lens[S, T] { } import scala.quoted._ -import scala.tasty._ object Lens { def apply[S, T](_get: S => T)(_set: T => S => S): Lens[S, T] = new Lens { diff --git a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala index b734f4998388..8646d47c139a 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) inline def foo(i: => Int): Int = ${ fooImpl('i) } - def fooImpl(i: Expr[Int]): Expr[Int] = { + def fooImpl(i: Expr[Int]) given QuoteContext: Expr[Int] = { val y: Int = run(i) y } diff --git a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala index e2aa77480563..2004cfcf3d78 100644 --- a/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala +++ b/tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala @@ -4,7 +4,7 @@ import scala.quoted.autolift._ object Macros { inline def foo(i: => Int): Int = ${ fooImpl('i) } - def fooImpl(i: Expr[Int]): Expr[Int] = { + def fooImpl(i: Expr[Int]) given QuoteContext: Expr[Int] = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) val y: Int = run(i) y diff --git a/tests/pending/run/tasty-comments/quoted_1.scala b/tests/pending/run/tasty-comments/quoted_1.scala index 3146df70573c..4c6f4f46a2a0 100644 --- a/tests/pending/run/tasty-comments/quoted_1.scala +++ b/tests/pending/run/tasty-comments/quoted_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ object Macros { diff --git a/tests/pos-macros/i6171/Macro_1.scala b/tests/pos-macros/i6171/Macro_1.scala index 49282050158d..cf303e63ae12 100644 --- a/tests/pos-macros/i6171/Macro_1.scala +++ b/tests/pos-macros/i6171/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/pos-macros/i6535/Macro_1.scala b/tests/pos-macros/i6535/Macro_1.scala index 85f2e9788671..f645d54759c9 100644 --- a/tests/pos-macros/i6535/Macro_1.scala +++ b/tests/pos-macros/i6535/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/pos-macros/quote-nested-object/Macro_1.scala b/tests/pos-macros/quote-nested-object/Macro_1.scala index 9296fbb44da5..112b9ecc88c7 100644 --- a/tests/pos-macros/quote-nested-object/Macro_1.scala +++ b/tests/pos-macros/quote-nested-object/Macro_1.scala @@ -9,7 +9,7 @@ object Macro { inline def plus(inline n: Int, m: Int): Int = ${ plus(n, 'm) } - def plus(n: Int, m: Expr[Int]): Expr[Int] = + def plus(n: Int, m: Expr[Int]) given QuoteContext: Expr[Int] = if (n == 0) m else '{ ${n} + $m } @@ -17,7 +17,7 @@ object Macro { inline def plus(inline n: Int, m: Int): Int = ${ plus(n, 'm) } - def plus(n: Int, m: Expr[Int]): Expr[Int] = + def plus(n: Int, m: Expr[Int]) given QuoteContext: Expr[Int] = if (n == 0) m else '{ ${n} + $m } } diff --git a/tests/pos-macros/quote-whitebox-2/Macro_1.scala b/tests/pos-macros/quote-whitebox-2/Macro_1.scala index 19e1184054de..25c9a8b775be 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) = if (str.length == 1) str.charAt(0).toExpr else str.toExpr + def impl(str: String) given QuoteContext = if (str.length == 1) str.charAt(0).toExpr else str.toExpr } diff --git a/tests/pos-with-compiler/quote-0.scala b/tests/pos-with-compiler/quote-0.scala index c0d931d5ee3b..47d0e0315430 100644 --- a/tests/pos-with-compiler/quote-0.scala +++ b/tests/pos-with-compiler/quote-0.scala @@ -7,15 +7,15 @@ object Macros { inline def assert(expr: => Boolean): Unit = ${ assertImpl('expr) } - def assertImpl(expr: Expr[Boolean]) = + def assertImpl(expr: Expr[Boolean]) given QuoteContext = '{ if !($expr) then throw new AssertionError(s"failed assertion: ${${showExpr(expr)}}") } - def showExpr[T](expr: Expr[T]): Expr[String] = expr.toString + def showExpr[T](expr: Expr[T]) given QuoteContext: Expr[String] = expr.toString inline def power(inline n: Int, x: Double) = ${ powerCode(n, 'x) } - def powerCode(n: Int, x: Expr[Double]): Expr[Double] = + def powerCode(n: Int, x: Expr[Double]) given QuoteContext: Expr[Double] = if (n == 0) '{1.0} else if (n == 1) x else if (n % 2 == 0) '{ { val y = $x * $x; ${ powerCode(n / 2, 'y) } } } @@ -24,21 +24,24 @@ object Macros { class Test { - val program = '{ - import Macros._ + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - val x = 1 - assert(x != 0) + run { + val program = '{ + import Macros._ - ${ assertImpl('{x != 0}) } + val x = 1 + assert(x != 0) - val y = math.sqrt(2.0) + ${ assertImpl('{x != 0}) } - power(3, y) + val y = math.sqrt(2.0) - ${ powerCode(3, '{math.sqrt(2.0)}) } - } + power(3, y) - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - program.run + ${ powerCode(3, '{math.sqrt(2.0)}) } + } + + program + } } diff --git a/tests/pos/i5962.scala b/tests/pos/i5962.scala index 835b32f0a0c2..da9a5ccc1c67 100644 --- a/tests/pos/i5962.scala +++ b/tests/pos/i5962.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ class MatchFactory1[T, S[_]] { def f: Int = 2 @@ -7,7 +6,7 @@ class MatchFactory1[T, S[_]] { object MatcherFactory1 { - def impl[T: Type, S[_], M >: MatchFactory1[T, S] <: MatchFactory1[T, S] : Type](self: Expr[M])(implicit refl: Reflection, tpS: Type[S[T]]) = + def impl[T: Type, S[_], M >: MatchFactory1[T, S] <: MatchFactory1[T, S] : Type](self: Expr[M])(implicit qctx: QuoteContext, tpS: Type[S[T]]) = '{ val a = ${self}; a.f } } diff --git a/tests/pos/i6253.scala b/tests/pos/i6253.scala index a11e7b9dcebf..797dbea4e1e3 100644 --- a/tests/pos/i6253.scala +++ b/tests/pos/i6253.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty.Reflection object Macros { def impl(self: Expr[StringContext]) given QuoteContext: Expr[String] = self match { case '{ StringContext() } => '{""} diff --git a/tests/pos/quote-lift.scala b/tests/pos/quote-lift.scala index 3af8da39625c..b89369e6b9ac 100644 --- a/tests/pos/quote-lift.scala +++ b/tests/pos/quote-lift.scala @@ -1,6 +1,7 @@ import scala.quoted._ object Test { + delegate for QuoteContext = ??? '{ ${implicitly[Liftable[Int]].toExpr(1)} } diff --git a/tests/pos/quote-liftable-list-2.scala b/tests/pos/quote-liftable-list-2.scala index 6c946cc36334..b64e6ab43ddb 100644 --- a/tests/pos/quote-liftable-list-2.scala +++ b/tests/pos/quote-liftable-list-2.scala @@ -3,11 +3,11 @@ import scala.quoted._ object Test { implicit def ListIsLiftableOr[T: Type, U: Type]: Liftable[List[T | U]] = new { - def toExpr(xs: List[T | U]): Expr[List[T | U]] = '{ Nil: List[T | U] } + def toExpr(xs: List[T | U]) given QuoteContext: Expr[List[T | U]] = '{ Nil: List[T | U] } } implicit def ListIsLiftableAnd[T: Type, U: Type]: Liftable[List[T & U]] = new { - def toExpr(xs: List[T & U]): Expr[List[T & U]] = '{ Nil: List[T & U] } + def toExpr(xs: List[T & U]) given QuoteContext: Expr[List[T & U]] = '{ Nil: List[T & U] } } } diff --git a/tests/pos/quote-liftable-list.scala b/tests/pos/quote-liftable-list.scala index 7b5e091b8b80..205315261fbd 100644 --- a/tests/pos/quote-liftable-list.scala +++ b/tests/pos/quote-liftable-list.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { - def toExpr(xs: List[T]): Expr[List[T]] = '{ Nil: List[T] } + def toExpr(xs: List[T]) given QuoteContext: Expr[List[T]] = '{ Nil: List[T] } } } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index 8b031f208498..0ba2b82e2c7a 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -2,8 +2,10 @@ import scala.quoted._ object Test { + delegate for QuoteContext = ??? + implicit def IntIsLiftable: Liftable[Int] = new { - def toExpr(n: Int): Expr[Int] = n match { + def toExpr(n: Int) given QuoteContext: Expr[Int] = n match { case Int.MinValue => '{Int.MinValue} case _ if n < 0 => '{- ${toExpr(n)}} case 0 => '{0} @@ -13,12 +15,12 @@ object Test { } implicit def BooleanIsLiftable: Liftable[Boolean] = new { - implicit def toExpr(b: Boolean) = + implicit def toExpr(b: Boolean) given QuoteContext: Expr[Boolean] = if (b) '{true} else '{false} } implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { - def toExpr(xs: List[T]): Expr[List[T]] = xs match { + def toExpr(xs: List[T]) given QuoteContext: Expr[List[T]] = xs match { case x :: xs1 => '{ ${ implicitly[Liftable[T]].toExpr(x) } :: ${ toExpr(xs1) } } case Nil => '{Nil: List[T]} } diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index 70d7e372ae64..3dff46b4d38a 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ import scala.quoted.autolift._ object Foo { diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index e0105c2ad9ea..5b8222c3c1c8 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ object Foo { diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index 34a0d3b42ebf..872c122652a2 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { implicit inline def printOwners[T](x: => T): Unit = 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 4a316d60bf27..9291e97e3da0 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 @@ -1,6 +1,5 @@ import scala.quoted._ -import scala.tasty._ object Foo { 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 5c97f8ef05bd..70945b772266 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 @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Foo { inline def inspectBody(i: => Int): String = diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index d6f514285c08..e86e129e5cc2 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty.Reflection import scala.quoted.autolift._ import scala.language.implicitConversions 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 51e96aeb6118..76523b4f5f90 100644 --- a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala @@ -2,7 +2,6 @@ // using staging reflection import scala.quoted._ -import scala.tasty._ object TypeToolbox { /** are the two types equal? */ @@ -113,7 +112,7 @@ object TypeToolbox { // TODO add to the std lib private implicit def listIsLiftable[T: Type: Liftable]: Liftable[List[T]] = new Liftable { - def toExpr(list: List[T]): Expr[List[T]] = list match { + def toExpr(list: List[T]) given QuoteContext: Expr[List[T]] = list match { case x :: xs => '{${x.toExpr} :: ${toExpr(xs)}} case Nil => '{Nil} } diff --git a/tests/run-macros/i4734/Macro_1.scala b/tests/run-macros/i4734/Macro_1.scala index 48028ca34861..ffbdfe3da8de 100644 --- a/tests/run-macros/i4734/Macro_1.scala +++ b/tests/run-macros/i4734/Macro_1.scala @@ -6,7 +6,7 @@ object Macros { inline def unrolledForeach(seq: IndexedSeq[Int], f: => Int => Unit, inline unrollSize: Int): Unit = // or f: Int => Unit ${ unrolledForeachImpl('seq, 'f, unrollSize) } - def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ + def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int) given QuoteContext: Expr[Unit] = '{ val size = ($seq).length assert(size % (${unrollSize}) == 0) // for simplicity of the implementation var i = 0 diff --git a/tests/run-macros/i4735/Macro_1.scala b/tests/run-macros/i4735/Macro_1.scala index 094137c60dde..408cdfe7591a 100644 --- a/tests/run-macros/i4735/Macro_1.scala +++ b/tests/run-macros/i4735/Macro_1.scala @@ -8,7 +8,7 @@ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int], f: => Int => Unit): Unit = // or f: Int => Unit ${ unrolledForeachImpl(unrollSize, 'seq, 'f) } - private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ + private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]) given QuoteContext: Expr[Unit] = '{ val size = ($seq).length assert(size % (${unrollSize}) == 0) // for simplicity of the implementation var i = 0 diff --git a/tests/run-macros/i5119/Macro_1.scala b/tests/run-macros/i5119/Macro_1.scala index 37e854cb27c5..7d5bfa337a89 100644 --- a/tests/run-macros/i5119/Macro_1.scala +++ b/tests/run-macros/i5119/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty.Reflection import scala.quoted.autolift._ object Macro { diff --git a/tests/run-macros/i5119b/Macro_1.scala b/tests/run-macros/i5119b/Macro_1.scala index b8896a1f514f..2340143d8871 100644 --- a/tests/run-macros/i5119b/Macro_1.scala +++ b/tests/run-macros/i5119b/Macro_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection object Macro { diff --git a/tests/run-macros/i5188a/Macro_1.scala b/tests/run-macros/i5188a/Macro_1.scala index 2aa1a9d4cf1c..ea37eb5eb48c 100644 --- a/tests/run-macros/i5188a/Macro_1.scala +++ b/tests/run-macros/i5188a/Macro_1.scala @@ -3,5 +3,5 @@ import scala.quoted.autolift._ object Lib { inline def sum(inline args: Int*): Int = ${ impl(args: _*) } - def impl(args: Int*): Expr[Int] = args.sum + def impl(args: Int*) given QuoteContext: Expr[Int] = args.sum } diff --git a/tests/run-macros/i5533/Macro_1.scala b/tests/run-macros/i5533/Macro_1.scala index 35395dc22257..ac4cc27f4cb7 100644 --- a/tests/run-macros/i5533/Macro_1.scala +++ b/tests/run-macros/i5533/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/i5533b/Macro_1.scala b/tests/run-macros/i5533b/Macro_1.scala index b73027c05047..f35d2af3c854 100644 --- a/tests/run-macros/i5533b/Macro_1.scala +++ b/tests/run-macros/i5533b/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { def f(x: Int): Int = x diff --git a/tests/run-macros/i5536/Macro_1.scala b/tests/run-macros/i5536/Macro_1.scala index 236e5268bc4b..cf44684f695e 100644 --- a/tests/run-macros/i5536/Macro_1.scala +++ b/tests/run-macros/i5536/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} diff --git a/tests/run-macros/i5629/Macro_1.scala b/tests/run-macros/i5629/Macro_1.scala index e32f00d1e632..7036e66e9207 100644 --- a/tests/run-macros/i5629/Macro_1.scala +++ b/tests/run-macros/i5629/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object Macros { diff --git a/tests/run-macros/i5715/Macro_1.scala b/tests/run-macros/i5715/Macro_1.scala index 1b92a1adefaa..8e5db69c310d 100644 --- a/tests/run-macros/i5715/Macro_1.scala +++ b/tests/run-macros/i5715/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/i5941/macro_1.scala b/tests/run-macros/i5941/macro_1.scala index d715206cecf0..ff98000e709c 100644 --- a/tests/run-macros/i5941/macro_1.scala +++ b/tests/run-macros/i5941/macro_1.scala @@ -4,7 +4,6 @@ trait Lens[S, T] { } import scala.quoted._ -import scala.tasty._ object Lens { def apply[S, T](_get: S => T)(_set: T => S => S): Lens[S, T] = new Lens { diff --git a/tests/run-macros/i6171/Macro_1.scala b/tests/run-macros/i6171/Macro_1.scala index 67ae0babb46a..07df0ba5ff3f 100644 --- a/tests/run-macros/i6171/Macro_1.scala +++ b/tests/run-macros/i6171/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/i6253-b/quoted_1.scala b/tests/run-macros/i6253-b/quoted_1.scala index 160892a8c855..85bbe915ba0f 100644 --- a/tests/run-macros/i6253-b/quoted_1.scala +++ b/tests/run-macros/i6253-b/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection - object Macros { inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)} diff --git a/tests/run-macros/i6253/quoted_1.scala b/tests/run-macros/i6253/quoted_1.scala index 0e57a5d6cf09..08176894a493 100644 --- a/tests/run-macros/i6253/quoted_1.scala +++ b/tests/run-macros/i6253/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection - object Macros { inline def (self: => StringContext) xyz(args: => String*): String = ${impl('self, 'args)} diff --git a/tests/run-macros/i6518/Macro_1.scala b/tests/run-macros/i6518/Macro_1.scala index 10d77ce49eee..2468da6846e1 100644 --- a/tests/run-macros/i6518/Macro_1.scala +++ b/tests/run-macros/i6518/Macro_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ object Macros { diff --git a/tests/run-macros/inferred-repeated-result/test_1.scala b/tests/run-macros/inferred-repeated-result/test_1.scala index 5a353c4712b7..2de5462d019b 100644 --- a/tests/run-macros/inferred-repeated-result/test_1.scala +++ b/tests/run-macros/inferred-repeated-result/test_1.scala @@ -1,7 +1,6 @@ object Macros { import scala.quoted._ import scala.quoted.autolift._ - import scala.tasty._ inline def go[T](t: => T) = ${ impl('t) } def impl[T](expr: Expr[T]) given (qctx: QuoteContext): Expr[Unit] = { diff --git a/tests/run-macros/inline-case-objects/Macro_1.scala b/tests/run-macros/inline-case-objects/Macro_1.scala index b48cd1c35294..3fddb091dab5 100644 --- a/tests/run-macros/inline-case-objects/Macro_1.scala +++ b/tests/run-macros/inline-case-objects/Macro_1.scala @@ -1,9 +1,8 @@ import scala.quoted._ -import scala.quoted.autolift._ object Macros { - def impl(foo: Any): Expr[String] = foo.getClass.getCanonicalName + def impl(foo: Any) given QuoteContext: Expr[String] = foo.getClass.getCanonicalName.toExpr } 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 7c90bbcaf338..7de649ff3dfe 100644 --- a/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala +++ b/tests/run-macros/inline-macro-staged-interpreter/Macro_1.scala @@ -1,33 +1,32 @@ import scala.quoted._ -import scala.quoted.autolift._ object E { inline def eval[T](inline x: E[T]): T = ${ impl(x) } - def impl[T](x: E[T]): Expr[T] = x.lift + def impl[T](x: E[T]) given QuoteContext: Expr[T] = x.lift } trait E[T] { - def lift: Expr[T] + def lift given QuoteContext: Expr[T] } case class I(n: Int) extends E[Int] { - def lift: Expr[Int] = n + def lift given QuoteContext: Expr[Int] = n.toExpr } case class D(n: Double) extends E[Double] { - def lift: Expr[Double] = n + def lift given QuoteContext: Expr[Double] = n.toExpr } case class Plus[T](x: E[T], y: E[T])(implicit op: Plus2[T]) extends E[T] { - def lift: Expr[T] = op(x.lift, y.lift) + def lift given QuoteContext: Expr[T] = op(x.lift, y.lift) } case class Times[T](x: E[T], y: E[T])(implicit op: Times2[T]) extends E[T] { - def lift: Expr[T] = op(x.lift, y.lift) + def lift given QuoteContext: Expr[T] = op(x.lift, y.lift) } trait Op2[T] { diff --git a/tests/run-macros/inline-option/Macro_1.scala b/tests/run-macros/inline-option/Macro_1.scala index 15fc19057981..e24f61fc4656 100644 --- a/tests/run-macros/inline-option/Macro_1.scala +++ b/tests/run-macros/inline-option/Macro_1.scala @@ -4,11 +4,11 @@ import scala.quoted.autolift._ object Macros { - def impl(opt: Option[Int]): Expr[Int] = opt match { + def impl(opt: Option[Int]) given QuoteContext: Expr[Int] = opt match { case Some(i) => i case None => '{-1} } - def impl2(opt: Option[Option[Int]]): Expr[Int] = impl(opt.flatten) + def impl2(opt: Option[Option[Int]]) given QuoteContext: Expr[Int] = impl(opt.flatten) } diff --git a/tests/run-macros/inline-tuples-1/Macro_1.scala b/tests/run-macros/inline-tuples-1/Macro_1.scala index ad2439520403..4c2524d50e5a 100644 --- a/tests/run-macros/inline-tuples-1/Macro_1.scala +++ b/tests/run-macros/inline-tuples-1/Macro_1.scala @@ -3,26 +3,26 @@ import scala.quoted._ import scala.quoted.autolift._ object Macros { - def tup1(tup: Tuple1[Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup2(tup: Tuple2[Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup3(tup: Tuple3[Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup4(tup: Tuple4[Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup5(tup: Tuple5[Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup6(tup: Tuple6[Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup7(tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup8(tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup9(tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup10(tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup11(tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup12(tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup13(tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup14(tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup15(tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup16(tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup17(tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup18(tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup19(tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup20(tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup21(tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum - def tup22(tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]): Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup1(tup: Tuple1[Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup2(tup: Tuple2[Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup3(tup: Tuple3[Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup4(tup: Tuple4[Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup5(tup: Tuple5[Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup6(tup: Tuple6[Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup7(tup: Tuple7[Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup8(tup: Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup9(tup: Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup10(tup: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup11(tup: Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup12(tup: Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup13(tup: Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup14(tup: Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup15(tup: Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup16(tup: Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup17(tup: Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup18(tup: Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup19(tup: Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup20(tup: Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup21(tup: Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum + def tup22(tup: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]) given QuoteContext: Expr[Int] = tup.productIterator.map(_.asInstanceOf[Int]).sum } diff --git a/tests/run-macros/inline-tuples-2/Macro_1.scala b/tests/run-macros/inline-tuples-2/Macro_1.scala index 1beb6c6dd35f..a8bc875d252f 100644 --- a/tests/run-macros/inline-tuples-2/Macro_1.scala +++ b/tests/run-macros/inline-tuples-2/Macro_1.scala @@ -4,8 +4,8 @@ import scala.quoted.autolift._ object Macros { - def impl(tup: Tuple1[Int]): Expr[Int] = tup._1 + def impl(tup: Tuple1[Int]) given QuoteContext: Expr[Int] = tup._1 - def impl2(tup: Tuple1[Tuple1[Int]]): Expr[Int] = impl(tup._1) + def impl2(tup: Tuple1[Tuple1[Int]]) given QuoteContext: Expr[Int] = impl(tup._1) } diff --git a/tests/run-macros/inline-varargs-1/Macro_1.scala b/tests/run-macros/inline-varargs-1/Macro_1.scala index 511c66e31ddf..8e90266eca52 100644 --- a/tests/run-macros/inline-varargs-1/Macro_1.scala +++ b/tests/run-macros/inline-varargs-1/Macro_1.scala @@ -3,5 +3,5 @@ import scala.quoted._ import scala.quoted.autolift._ object Macros { - def sum(nums: Int*): Expr[Int] = nums.sum + def sum(nums: Int*) given QuoteContext: Expr[Int] = nums.sum } diff --git a/tests/run-macros/quote-force/quoted_1.scala b/tests/run-macros/quote-force/quoted_1.scala index 605de9311f3a..86f3fdbe7e7b 100644 --- a/tests/run-macros/quote-force/quoted_1.scala +++ b/tests/run-macros/quote-force/quoted_1.scala @@ -7,13 +7,15 @@ object Location { implicit inline def location: Location = ${impl} - def impl: Expr[Location] = { + def impl given QuoteContext: Expr[Location] = { val list = List("a", "b", "c", "d", "e", "f") '{new Location(${list})} } - private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = { - case x :: xs => '{ ${x} :: ${xs} } - case Nil => '{ List.empty[T] } + private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = new Liftable[List[T]] { + def toExpr(x: List[T]) given QuoteContext: Expr[List[T]] = x match { + case x :: xs => '{ ${x} :: ${xs} } + case Nil => '{ List.empty[T] } + } } } diff --git a/tests/run-macros/quote-impure-by-name/quoted_1.scala b/tests/run-macros/quote-impure-by-name/quoted_1.scala index b6a6fa0b4093..031427770025 100644 --- a/tests/run-macros/quote-impure-by-name/quoted_1.scala +++ b/tests/run-macros/quote-impure-by-name/quoted_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection class Index[K, Keys](val index: String) extends AnyVal { override def toString: String = index diff --git a/tests/run-macros/quote-inline-function/quoted_1.scala b/tests/run-macros/quote-inline-function/quoted_1.scala index 92669be3d12d..860d9aea942d 100644 --- a/tests/run-macros/quote-inline-function/quoted_1.scala +++ b/tests/run-macros/quote-inline-function/quoted_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection object Macros { diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index 1f1c324cc5ec..de2b3a777736 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection object Macros { 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 62413775fe02..fe1a1a22f1ef 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 @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection object Macros { 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 d04ce3225687..5e8d5f4fbfaa 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 @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection object Macros { diff --git a/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala b/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala index beab437e983f..bdc9b16c15bf 100644 --- a/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala +++ b/tests/run-macros/quote-matcher-string-interpolator/quoted_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection object Macros { 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 8658580efe29..3cc44df56786 100644 --- a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala @@ -2,9 +2,6 @@ import scala.quoted._ import scala.quoted.matching._ -import scala.tasty.Reflection - - object Macros { inline def lift[T](sym: Symantics[T])(a: => DSL): T = ${impl[T]('sym, 'a)} 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 a7666247db05..4cd7c8f7f19b 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -61,7 +61,7 @@ case class LitDSL(x: Int) extends DSL // trait Symantics[Num] { - def value(x: Int): Expr[Num] + def value(x: Int) given QuoteContext: Expr[Num] def plus(x: Expr[Num], y: Expr[Num]): Expr[Num] def times(x: Expr[Num], y: Expr[Num]): Expr[Num] def app(f: Expr[Num => Num], x: Expr[Num]): Expr[Num] @@ -69,7 +69,7 @@ trait Symantics[Num] { } object StringNum extends Symantics[String] { - def value(x: Int): Expr[String] = x.toString.toExpr + def value(x: Int) given QuoteContext: Expr[String] = x.toString.toExpr def plus(x: Expr[String], y: Expr[String]): Expr[String] = '{ s"${$x} + ${$y}" } // '{ x + " + " + y } def times(x: Expr[String], y: Expr[String]): Expr[String] = '{ s"${$x} * ${$y}" } def app(f: Expr[String => String], x: Expr[String]): 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): Expr[Int] = x.toExpr + def value(x: Int) given QuoteContext: Expr[Int] = x.toExpr def plus(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{ $x + $y } def times(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{ $x * $y } def app(f: Expr[Int => Int], x: Expr[Int]): Expr[Int] = '{ $f($x) } @@ -85,7 +85,7 @@ object ComputeNum extends Symantics[Int] { } object ASTNum extends Symantics[ASTNum] { - def value(x: Int): Expr[ASTNum] = '{ LitAST(${x.toExpr}) } + def value(x: Int) given QuoteContext: Expr[ASTNum] = '{ LitAST(${x.toExpr}) } def plus(x: Expr[ASTNum], y: Expr[ASTNum]): Expr[ASTNum] = '{ PlusAST($x, $y) } def times(x: Expr[ASTNum], y: Expr[ASTNum]): Expr[ASTNum] = '{ TimesAST($x, $y) } def app(f: Expr[ASTNum => ASTNum], x: Expr[ASTNum]): Expr[ASTNum] = '{ AppAST($f, $x) } diff --git a/tests/run-macros/quote-simple-macro/quoted_1.scala b/tests/run-macros/quote-simple-macro/quoted_1.scala index 272ef07a09ae..41700d548e0a 100644 --- a/tests/run-macros/quote-simple-macro/quoted_1.scala +++ b/tests/run-macros/quote-simple-macro/quoted_1.scala @@ -3,5 +3,5 @@ import scala.quoted.autolift._ object Macros { inline def foo(inline i: Int, dummy: Int, j: Int): Int = ${ bar(i, 'j) } - def bar(x: Int, y: Expr[Int]): Expr[Int] = '{ ${x} + $y } + def bar(x: Int, y: Expr[Int]) given QuoteContext: Expr[Int] = '{ ${x} + $y } } diff --git a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala index 506f41ec79da..9ff9f7615b0c 100644 --- a/tests/run-macros/quote-unrolled-foreach/quoted_1.scala +++ b/tests/run-macros/quote-unrolled-foreach/quoted_1.scala @@ -7,7 +7,7 @@ object Macro { inline def unrolledForeach(inline unrollSize: Int, seq: Array[Int])(f: => Int => Unit): Unit = // or f: Int => Unit ${unrolledForeachImpl(unrollSize, 'seq, 'f)} - private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ + private def unrolledForeachImpl(unrollSize: Int, seq: Expr[Array[Int]], f: Expr[Int => Unit]) given QuoteContext: Expr[Unit] = '{ val size = $seq.length assert(size % (${unrollSize}) == 0) // for simplicity of the implementation var i = 0 diff --git a/tests/run-macros/reflect-dsl/assert_1.scala b/tests/run-macros/reflect-dsl/assert_1.scala index 837e568651cf..7692ea6ec098 100644 --- a/tests/run-macros/reflect-dsl/assert_1.scala +++ b/tests/run-macros/reflect-dsl/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-isFunctionType/macro_1.scala b/tests/run-macros/reflect-isFunctionType/macro_1.scala index c9522f9a0ce5..0c4e91861ec0 100644 --- a/tests/run-macros/reflect-isFunctionType/macro_1.scala +++ b/tests/run-macros/reflect-isFunctionType/macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ inline def isFunctionType[T:Type]: Boolean = ${ isFunctionTypeImpl('[T]) } diff --git a/tests/run-macros/reflect-pos-fun/assert_1.scala b/tests/run-macros/reflect-pos-fun/assert_1.scala index 6e418b676f9f..6f0c8b33275e 100644 --- a/tests/run-macros/reflect-pos-fun/assert_1.scala +++ b/tests/run-macros/reflect-pos-fun/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-select-constructor/assert_1.scala b/tests/run-macros/reflect-select-constructor/assert_1.scala index bd33d6ac2d35..3706dfde3d0a 100644 --- a/tests/run-macros/reflect-select-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-constructor/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-select-copy/assert_1.scala b/tests/run-macros/reflect-select-copy/assert_1.scala index 87e0252e1506..55f180275194 100644 --- a/tests/run-macros/reflect-select-copy/assert_1.scala +++ b/tests/run-macros/reflect-select-copy/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala b/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala index 4ee21ff1cb3d..68e88be7bb67 100644 --- a/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala +++ b/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala index 27541de03230..7fcd27a55439 100644 --- a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-select-value-class/assert_1.scala b/tests/run-macros/reflect-select-value-class/assert_1.scala index bd33d6ac2d35..3706dfde3d0a 100644 --- a/tests/run-macros/reflect-select-value-class/assert_1.scala +++ b/tests/run-macros/reflect-select-value-class/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/reflect-typeChecks/assert_1.scala b/tests/run-macros/reflect-typeChecks/assert_1.scala index 1f65f528f31e..bcc6e6b6d1f9 100644 --- a/tests/run-macros/reflect-typeChecks/assert_1.scala +++ b/tests/run-macros/reflect-typeChecks/assert_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object scalatest { diff --git a/tests/run-macros/tasty-argument-tree-1/quoted_1.scala b/tests/run-macros/tasty-argument-tree-1/quoted_1.scala index 145c3ee0be82..ef7b8596cbfc 100644 --- a/tests/run-macros/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run-macros/tasty-argument-tree-1/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { inline def inspect[T](x: T): Unit = ${ impl('x) } diff --git a/tests/run-macros/tasty-custom-show/quoted_1.scala b/tests/run-macros/tasty-custom-show/quoted_1.scala index 7ec8c7255815..30239facfb4e 100644 --- a/tests/run-macros/tasty-custom-show/quoted_1.scala +++ b/tests/run-macros/tasty-custom-show/quoted_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection object Macros { diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index 753e4e75bcd5..e4332f2652b7 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object Macros { diff --git a/tests/run-macros/tasty-definitions-1/quoted_1.scala b/tests/run-macros/tasty-definitions-1/quoted_1.scala index f3edcaa18530..8ddfcbce595c 100644 --- a/tests/run-macros/tasty-definitions-1/quoted_1.scala +++ b/tests/run-macros/tasty-definitions-1/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { inline def testDefinitions(): Unit = ${testDefinitionsImpl} diff --git a/tests/run-macros/tasty-eval/quoted_1.scala b/tests/run-macros/tasty-eval/quoted_1.scala index 826e118211b9..4352ea44fe69 100644 --- a/tests/run-macros/tasty-eval/quoted_1.scala +++ b/tests/run-macros/tasty-eval/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { implicit inline def foo(i: Int): String = diff --git a/tests/run-macros/tasty-extractors-1/quoted_1.scala b/tests/run-macros/tasty-extractors-1/quoted_1.scala index f35e3fbe3ea2..2ef08ce8e8d6 100644 --- a/tests/run-macros/tasty-extractors-1/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-1/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { implicit inline def printTree[T](x: => T): Unit = diff --git a/tests/run-macros/tasty-extractors-2/quoted_1.scala b/tests/run-macros/tasty-extractors-2/quoted_1.scala index 5a6b8dedf802..e1aa303b7dfd 100644 --- a/tests/run-macros/tasty-extractors-2/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-2/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { implicit inline def printTree[T](x: => T): Unit = diff --git a/tests/run-macros/tasty-extractors-3/quoted_1.scala b/tests/run-macros/tasty-extractors-3/quoted_1.scala index 531f95f15313..da4943128d59 100644 --- a/tests/run-macros/tasty-extractors-3/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-3/quoted_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ -import scala.tasty.Reflection import scala.quoted.autolift._ object Macros { 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 19730a72fca9..a74ae5a48cc6 100644 --- a/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-constants-1/quoted_1.scala @@ -3,7 +3,6 @@ import scala.quoted.autolift._ import scala.quoted.matching._ -import scala.tasty._ import scala.tasty.util._ object Macros { diff --git a/tests/run-macros/tasty-extractors-types/quoted_1.scala b/tests/run-macros/tasty-extractors-types/quoted_1.scala index 97243af0b9c7..5ca101f388e5 100644 --- a/tests/run-macros/tasty-extractors-types/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-types/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { implicit inline def printType[T]: Unit = ${ impl('[T]) } diff --git a/tests/run-macros/tasty-getfile/Macro_1.scala b/tests/run-macros/tasty-getfile/Macro_1.scala index a5959ae486a9..b3da537b969a 100644 --- a/tests/run-macros/tasty-getfile/Macro_1.scala +++ b/tests/run-macros/tasty-getfile/Macro_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection object SourceFiles { diff --git a/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala b/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala index 8dc4b4643009..d2910e0771a1 100644 --- a/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala +++ b/tests/run-macros/tasty-implicit-fun-context-2/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty.Reflection object Foo { diff --git a/tests/run-macros/tasty-indexed-map/quoted_1.scala b/tests/run-macros/tasty-indexed-map/quoted_1.scala index 9974db0f76bc..8d7435d036fb 100644 --- a/tests/run-macros/tasty-indexed-map/quoted_1.scala +++ b/tests/run-macros/tasty-indexed-map/quoted_1.scala @@ -2,8 +2,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - class MyMap[Keys](private val underlying: Array[Int]) extends AnyVal { def get[K <: String](implicit i: Index[K, Keys]): Int = underlying(i.index) def set[K <: String](value: Int)(implicit i: Index[K, Keys]): Unit = underlying(i.index) = value diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index 56bca47ca958..2967104d2b14 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -1,6 +1,5 @@ import scala.quoted._ -import scala.tasty.Reflection import scala.language.implicitConversions import scala.quoted.autolift._ @@ -75,10 +74,10 @@ abstract class MacroStringInterpolator[T] { } protected implicit def StringContextIsLiftable: Liftable[StringContext] = new Liftable[StringContext] { - def toExpr(strCtx: StringContext): Expr[StringContext] = { + def toExpr(strCtx: StringContext) given QuoteContext: Expr[StringContext] = { // TODO define in stdlib? implicit def ListIsLiftable: Liftable[List[String]] = new Liftable[List[String]] { - override def toExpr(list: List[String]): Expr[List[String]] = list match { + override def toExpr(list: List[String]) given QuoteContext: Expr[List[String]] = list match { case x :: xs => '{${x.toExpr} :: ${toExpr(xs)}} case Nil => '{Nil} } diff --git a/tests/run-macros/tasty-linenumber-2/quoted_1.scala b/tests/run-macros/tasty-linenumber-2/quoted_1.scala index eaf1c379c523..905c46c28e8f 100644 --- a/tests/run-macros/tasty-linenumber-2/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber-2/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - class LineNumber(val value: Int) { override def toString: String = value.toString } diff --git a/tests/run-macros/tasty-linenumber/quoted_1.scala b/tests/run-macros/tasty-linenumber/quoted_1.scala index 520fe9ea5752..c47de1566c59 100644 --- a/tests/run-macros/tasty-linenumber/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - class LineNumber(val value: Int) { override def toString: String = value.toString } diff --git a/tests/run-macros/tasty-location/quoted_1.scala b/tests/run-macros/tasty-location/quoted_1.scala index 849425e6c832..850de61bf4ec 100644 --- a/tests/run-macros/tasty-location/quoted_1.scala +++ b/tests/run-macros/tasty-location/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - case class Location(owners: List[String]) object Location { @@ -20,8 +18,10 @@ object Location { '{new Location(${list})} } - private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = { - case x :: xs => '{ ${x} :: ${xs} } - case Nil => '{ List.empty[T] } + private implicit def ListIsLiftable[T : Liftable : Type]: Liftable[List[T]] = new Liftable[List[T]] { + def toExpr(x: List[T]) given QuoteContext: Expr[List[T]] = x match { + case x :: xs => '{ $x :: $xs } + case Nil => '{ List.empty[T] } + } } } diff --git a/tests/run-macros/tasty-macro-assert/quoted_1.scala b/tests/run-macros/tasty-macro-assert/quoted_1.scala index 33d929f61c8f..fddf356e8963 100644 --- a/tests/run-macros/tasty-macro-assert/quoted_1.scala +++ b/tests/run-macros/tasty-macro-assert/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Asserts { implicit class Ops[T](left: T) { diff --git a/tests/run-macros/tasty-macro-const/quoted_1.scala b/tests/run-macros/tasty-macro-const/quoted_1.scala index 29e5638a6bdc..51fbbd75cf4d 100644 --- a/tests/run-macros/tasty-macro-const/quoted_1.scala +++ b/tests/run-macros/tasty-macro-const/quoted_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object Macros { diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index 3661d24fc9b2..39912aa373bf 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Macros { inline def fun(x: Any): Unit = ${ impl('x) } @@ -31,6 +29,7 @@ object Macros { } def posStr(qctx: QuoteContext)(pos: qctx.tasty.Position): Expr[String] = { + delegate for QuoteContext = qctx import qctx.tasty._ s"${pos.sourceFile.jpath.getFileName.toString}:[${pos.start}..${pos.end}]".toExpr } diff --git a/tests/run-macros/tasty-original-source/Macros_1.scala b/tests/run-macros/tasty-original-source/Macros_1.scala index 5d2cf19fbd6c..6ccde3553d8c 100644 --- a/tests/run-macros/tasty-original-source/Macros_1.scala +++ b/tests/run-macros/tasty-original-source/Macros_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { implicit inline def withSource(arg: Any): (String, Any) = ${ impl('arg) } diff --git a/tests/run-macros/tasty-seal-method/quoted_1.scala b/tests/run-macros/tasty-seal-method/quoted_1.scala index 75ffa8a4b201..9c294c37b6e7 100644 --- a/tests/run-macros/tasty-seal-method/quoted_1.scala +++ b/tests/run-macros/tasty-seal-method/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Asserts { inline def zeroLastArgs(x: => Int): Int = diff --git a/tests/run-macros/tasty-subtyping/quoted_1.scala b/tests/run-macros/tasty-subtyping/quoted_1.scala index 984839764892..51b28284bd85 100644 --- a/tests/run-macros/tasty-subtyping/quoted_1.scala +++ b/tests/run-macros/tasty-subtyping/quoted_1.scala @@ -1,8 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ - object Macros { inline def isTypeEqual[T, U]: Boolean = diff --git a/tests/run-macros/tasty-tree-map/quoted_1.scala b/tests/run-macros/tasty-tree-map/quoted_1.scala index 8e2aa3e50ac5..b2cae87e7ff8 100644 --- a/tests/run-macros/tasty-tree-map/quoted_1.scala +++ b/tests/run-macros/tasty-tree-map/quoted_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object Macros { diff --git a/tests/run-macros/tasty-typeof/Macro_1.scala b/tests/run-macros/tasty-typeof/Macro_1.scala index d6163e25b9c7..e81eee70f76d 100644 --- a/tests/run-macros/tasty-typeof/Macro_1.scala +++ b/tests/run-macros/tasty-typeof/Macro_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ object Macros { diff --git a/tests/run-macros/type-show/Macro_1.scala b/tests/run-macros/type-show/Macro_1.scala index 539e4a40a411..64d096a03394 100644 --- a/tests/run-macros/type-show/Macro_1.scala +++ b/tests/run-macros/type-show/Macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ object TypeToolbox { inline def show[A]: String = ${ showImpl('[A]) } diff --git a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala index 6f5f3aac0824..93024be0748a 100644 --- a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection import scala.language.implicitConversions diff --git a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala index 0f1066044c21..8cded8fa6437 100644 --- a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala @@ -2,7 +2,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection import scala.language.implicitConversions diff --git a/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala index af16eb4204ba..557bfd00881c 100644 --- a/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-3/XmlQuote_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection import scala.language.implicitConversions @@ -13,7 +12,7 @@ object XmlQuote { ${XmlQuote.impl(ctx, 'args)} } - def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = { + def impl(receiver: StringContext, args: Expr[Seq[Any]]) given QuoteContext: Expr[Xml] = { val string = receiver.parts.mkString("??") '{new Xml(${string}, $args.toList)} } diff --git a/tests/run-macros/xml-interpolation-4/Macros_1.scala b/tests/run-macros/xml-interpolation-4/Macros_1.scala index 1dabaf14faf3..b828617e9f43 100644 --- a/tests/run-macros/xml-interpolation-4/Macros_1.scala +++ b/tests/run-macros/xml-interpolation-4/Macros_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty.Reflection import scala.language.implicitConversions diff --git a/tests/run-with-compiler-custom-args/staged-streams_1.scala b/tests/run-with-compiler-custom-args/staged-streams_1.scala index 1a6a716f8b31..3e75c0d7c68d 100644 --- a/tests/run-with-compiler-custom-args/staged-streams_1.scala +++ b/tests/run-with-compiler-custom-args/staged-streams_1.scala @@ -61,7 +61,7 @@ object Test { * @param k the continuation that is invoked after the new state is defined in the body of `init` * @return expr value of unit per the CPS-encoding */ - def init(k: St => Expr[Unit]): Expr[Unit] + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] /** Step method that defines the transformation of data. * @@ -98,7 +98,7 @@ object Test { * @tparam W the type of the accumulator * @return */ - def fold[W: Type](z: Expr[W], f: ((Expr[W], Expr[A]) => Expr[W])): Expr[W] = { + def fold[W: Type](z: Expr[W], f: ((Expr[W], Expr[A]) => Expr[W])) given QuoteContext: Expr[W] = { Var(z) { s: Var[W] => '{ ${ foldRaw[Expr[A]]((a: Expr[A]) => '{ @@ -110,7 +110,7 @@ object Test { } } - private def foldRaw[A](consumer: A => Expr[Unit], stream: StagedStream[A]): Expr[Unit] = { + private def foldRaw[A](consumer: A => Expr[Unit], stream: StagedStream[A]) given QuoteContext: Expr[Unit] = { stream match { case Linear(producer) => { producer.card match { @@ -166,7 +166,7 @@ object Test { type St = producer.St val card = producer.card - def init(k: St => Expr[Unit]): Expr[Unit] = { + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = { producer.init(k) } @@ -229,7 +229,7 @@ object Test { type St = Expr[A] val card = AtMost1 - def init(k: St => Expr[Unit]): Expr[Unit] = + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = k(a) def step(st: St, k: (Expr[A] => Expr[Unit])): Expr[Unit] = @@ -259,7 +259,7 @@ object Test { type St = producer.St val card = producer.card - def init(k: St => Expr[Unit]): Expr[Unit] = + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = producer.init(k) def step(st: St, k: (A => Expr[Unit])): Expr[Unit] = @@ -292,7 +292,7 @@ object Test { type St = (Var[Int], producer.St) val card = producer.card - def init(k: St => Expr[Unit]): Expr[Unit] = { + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = { producer.init(st => { Var(n) { counter => k(counter, st) @@ -441,7 +441,7 @@ object Test { * @param k the continuation that consumes a variable. * @return the quote of the orchestrated code that will be executed as */ - def makeAdvanceFunction[A](nadv: Var[Unit => Unit], k: A => Expr[Unit], stream: StagedStream[A]): Expr[Unit] = { + def makeAdvanceFunction[A](nadv: Var[Unit => Unit], k: A => Expr[Unit], stream: StagedStream[A]) given QuoteContext: Expr[Unit] = { stream match { case Linear(producer) => producer.card match { @@ -482,7 +482,7 @@ object Test { type St = (Var[Boolean], Var[A], Var[Unit => Unit]) val card: Cardinality = Many - def init(k: St => Expr[Unit]): Expr[Unit] = { + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = { producer.init(st => Var('{ (_: Unit) => ()}){ nadv => { Var('{ true }) { hasNext => { @@ -532,7 +532,7 @@ object Test { type St = (Var[Boolean], producer.St, nestedProducer.St) val card: Cardinality = Many - def init(k: St => Expr[Unit]): Expr[Unit] = { + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = { producer.init(s1 => '{ ${nestedProducer.init(s2 => Var(producer.hasNext(s1)) { flag => k((flag, s1, s2)) @@ -567,7 +567,7 @@ object Test { type St = (producer1.St, producer2.St) val card: Cardinality = Many - def init(k: St => Expr[Unit]): Expr[Unit] = { + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = { producer1.init(s1 => producer2.init(s2 => k((s1, s2)) )) } @@ -597,7 +597,7 @@ object Test { val card = Many - def init(k: St => Expr[Unit]): Expr[Unit] = { + def init(k: St => Expr[Unit]) given QuoteContext: Expr[Unit] = { Var('{($arr).length}) { n => Var(0){ i => k((i, n, arr)) @@ -626,52 +626,52 @@ object Test { } } - def test1() = Stream + def test1() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test2() = Stream + def test2() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .map((a: Expr[Int]) => '{ $a * 2 }) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test3() = Stream + def test3() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d * $dp })) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test4() = Stream + def test4() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .filter((d: Expr[Int]) => '{ $d % 2 == 0 }) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test5() = Stream + def test5() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .take('{2}) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test6() = Stream + def test6() given QuoteContext = Stream .of('{Array(1, 1, 1)}) .flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).take('{2})) .take('{5}) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test7() = Stream + def test7() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)})) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test8() = Stream + def test8() given QuoteContext = Stream .of('{Array(1, 2, 3)}) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp }))) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test9() = Stream + def test9() given QuoteContext = Stream .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}) ) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) - def test10() = Stream + def test10() given QuoteContext = Stream .of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) .zip(((a : Expr[Int]) => (b : Expr[Int]) => '{ $a + $b }), Stream.of('{Array(1, 2, 3)}).flatMap((d: Expr[Int]) => Stream.of('{Array(1, 2, 3)}).map((dp: Expr[Int]) => '{ $d + $dp })) ) .fold('{0}, ((a: Expr[Int], b : Expr[Int]) => '{ $a + $b })) @@ -699,6 +699,3 @@ object Test { println(run(test10())) } } - - - diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/Test.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/Test.scala index 96212d50d70b..9134c304cc7f 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/Test.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/Test.scala @@ -9,7 +9,6 @@ import dotty.tools.io.Path import scala.io.Source import scala.tasty.file._ import scala.tasty.interpreter.TastyInterpreter -import scala.tasty.Reflection object Test { def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/i3847-b.scala b/tests/run-with-compiler/i3847-b.scala index a07c47ceefad..1d6171b40d30 100644 --- a/tests/run-with-compiler/i3847-b.scala +++ b/tests/run-with-compiler/i3847-b.scala @@ -4,7 +4,7 @@ import scala.reflect.ClassTag object Arrays { implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T]): Liftable[Array[List[T]]] = { new Liftable[Array[List[T]]] { - def toExpr(arr: Array[List[T]]): Expr[Array[List[T]]] = '{ + def toExpr(arr: Array[List[T]]) given QuoteContext: Expr[Array[List[T]]] = '{ new Array[List[$t]](${arr.length.toExpr}) // TODO add elements } diff --git a/tests/run-with-compiler/i3847.scala b/tests/run-with-compiler/i3847.scala index 4c05714d1767..c59ea5abfb58 100644 --- a/tests/run-with-compiler/i3847.scala +++ b/tests/run-with-compiler/i3847.scala @@ -4,7 +4,7 @@ import scala.reflect.ClassTag 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]): Expr[Array[T]] = '{ + def toExpr(arr: Array[T]) given QuoteContext: Expr[Array[T]] = '{ new Array[$t](${arr.length.toExpr})($ct) // TODO add elements } diff --git a/tests/run-with-compiler/i5161.scala b/tests/run-with-compiler/i5161.scala index e1ea118ae76c..407ef023466f 100644 --- a/tests/run-with-compiler/i5161.scala +++ b/tests/run-with-compiler/i5161.scala @@ -9,7 +9,7 @@ object Test { } import Exp._ - def evalTest(e: Exp): Expr[Option[Int]] = e match { + def evalTest(e: Exp) given QuoteContext: Expr[Option[Int]] = e match { case Int2(x) => '{ Some(${x.toExpr}) } case Add(e1, e2) => '{ @@ -24,7 +24,7 @@ object Test { def main(args: Array[String]): Unit = { val test = Add(Int2(1), Int2(1)) - val res = evalTest(test) + def res given QuoteContext = evalTest(test) println("run : " + run(res)) println("show : " + withQuoteContext(res.show)) } diff --git a/tests/run-with-compiler/i5965.scala b/tests/run-with-compiler/i5965.scala index 7b1a8cfa61a7..31cab4e746bb 100644 --- a/tests/run-with-compiler/i5965.scala +++ b/tests/run-with-compiler/i5965.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Test { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) diff --git a/tests/run-with-compiler/i5965b.scala b/tests/run-with-compiler/i5965b.scala index e806cd847957..04d989cd9123 100644 --- a/tests/run-with-compiler/i5965b.scala +++ b/tests/run-with-compiler/i5965b.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Test { def main(args: Array[String]): Unit = { diff --git a/tests/run-with-compiler/i6201/macro_1.scala b/tests/run-with-compiler/i6201/macro_1.scala index 52c6a693943d..cbbad024cdd8 100644 --- a/tests/run-with-compiler/i6201/macro_1.scala +++ b/tests/run-with-compiler/i6201/macro_1.scala @@ -1,5 +1,4 @@ import scala.quoted._ -import scala.tasty._ inline def (inline x: String) strip: String = ${ stripImpl(x) } diff --git a/tests/run-with-compiler/i6270/Macro_1.scala b/tests/run-with-compiler/i6270/Macro_1.scala index 2f151b4e8674..f9efa6195667 100644 --- a/tests/run-with-compiler/i6270/Macro_1.scala +++ b/tests/run-with-compiler/i6270/Macro_1.scala @@ -1,6 +1,5 @@ import scala.quoted._ import scala.quoted.show.SyntaxHighlight.ANSI -import scala.tasty._ object api { inline def (x: => String) reflect : String = diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala index 0c5c58d21d3b..e4a96762c1dd 100644 --- a/tests/run-with-compiler/quote-lib.scala +++ b/tests/run-with-compiler/quote-lib.scala @@ -47,14 +47,14 @@ package liftable { object Exprs { implicit class LiftExprOps[T](x: T) extends AnyVal { - def toExpr(implicit liftable: Liftable[T]): Expr[T] = - liftable.toExpr(x) + def toExpr given Liftable[T], QuoteContext: Expr[T] = + the[Liftable[T]].toExpr(x) } } object Units { implicit def UnitIsLiftable: Liftable[Unit] = new Liftable[Unit] { - def toExpr(x: Unit): Expr[Unit] = '{} + def toExpr(x: Unit) given QuoteContext: Expr[Unit] = '{} } } @@ -75,24 +75,24 @@ package liftable { object Tuples { implicit def Tuple1IsLiftable[T1: Liftable](implicit t1: Type[T1]): Liftable[Tuple1[T1]] = new Liftable[Tuple1[T1]] { - def toExpr(x: Tuple1[T1]): Expr[Tuple1[T1]] = + def toExpr(x: Tuple1[T1]) given QuoteContext: Expr[Tuple1[T1]] = '{ Tuple1[$t1](${ x._1}) } } implicit def Tuple2IsLiftable[T1: Liftable, T2: Liftable](implicit t1: Type[T1], t2: Type[T2]): Liftable[(T1, T2)] = new Liftable[(T1, T2)] { - def toExpr(x: (T1, T2)): Expr[(T1, T2)] = + def toExpr(x: (T1, T2)) given QuoteContext: Expr[(T1, T2)] = '{ Tuple2[$t1, $t2](${x._1}, ${x._2}) } } implicit def Tuple3IsLiftable[T1: Liftable, T2: Liftable, T3: Liftable](implicit t1: Type[T1], t2: Type[T2], t3: Type[T3]): Liftable[(T1, T2, T3)] = new Liftable[(T1, T2, T3)] { - def toExpr(x: (T1, T2, T3)): Expr[(T1, T2, T3)] = + def toExpr(x: (T1, T2, T3)) given QuoteContext: Expr[(T1, T2, T3)] = '{ Tuple3[$t1, $t2, $t3](${x._1}, ${x._2}, ${x._3}) } } implicit def Tuple4IsLiftable[T1: Liftable, T2: Liftable, T3: Liftable, T4: Liftable](implicit t1: Type[T1], t2: Type[T2], t3: Type[T3], t4: Type[T4]): Liftable[(T1, T2, T3, T4)] = new Liftable[(T1, T2, T3, T4)] { - def toExpr(x: (T1, T2, T3, T4)): Expr[(T1, T2, T3, T4)] = + def toExpr(x: (T1, T2, T3, T4)) given QuoteContext: Expr[(T1, T2, T3, T4)] = '{ Tuple4[$t1, $t2, $t3, $t4](${x._1}, ${x._2}, ${x._3}, ${x._4}) } } @@ -103,7 +103,7 @@ package liftable { object Lists { implicit def ListIsLiftable[T: Liftable](implicit t: Type[T]): Liftable[List[T]] = new Liftable[List[T]] { - def toExpr(x: List[T]): Expr[List[T]] = x match { + def toExpr(x: List[T]) given QuoteContext: Expr[List[T]] = x match { case x :: xs => '{ (${xs}).::[$t](${x}) } case Nil => '{ Nil: List[$t] } } @@ -116,7 +116,7 @@ package liftable { '{ ($list).foreach($f) } } - implicit class UnrolledOps[T: Liftable](list: List[T])(implicit t: Type[T]) { + implicit class UnrolledOps[T: Liftable](list: List[T])(implicit t: Type[T], qctx: QuoteContext) { def unrolledFoldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: Type[U]): Expr[U] = list match { case x :: xs => xs.unrolledFoldLeft('{ ($f).apply($acc, ${x}) })(f) case Nil => acc @@ -129,7 +129,7 @@ package liftable { 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]): Expr[Array[T]] = '{ new Array[$t](${arr.length})($ct) } + def toExpr(arr: Array[T]) given QuoteContext: Expr[Array[T]] = '{ new Array[$t](${arr.length})($ct) } } } diff --git a/tests/run-with-compiler/quote-run-constants.scala b/tests/run-with-compiler/quote-run-constants.scala index 63dab930879f..dbc1b22006e3 100644 --- a/tests/run-with-compiler/quote-run-constants.scala +++ b/tests/run-with-compiler/quote-run-constants.scala @@ -6,7 +6,7 @@ import scala.quoted._ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def runAndPrint[T](expr: Expr[T]): Unit = println(run(expr)) + def runAndPrint[T](expr: given QuoteContext => Expr[T]): Unit = println(run(expr)) runAndPrint(true) runAndPrint('a') diff --git a/tests/run-with-compiler/quote-run-many.scala b/tests/run-with-compiler/quote-run-many.scala index c788f8fb5d37..c8827a9074a4 100644 --- a/tests/run-with-compiler/quote-run-many.scala +++ b/tests/run-with-compiler/quote-run-many.scala @@ -4,7 +4,7 @@ import scala.quoted.autolift._ object Test { def main(args: Array[String]): Unit = { implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def expr(i: Int) = '{ + def expr(i: Int) given QuoteContext = '{ val a = 3 + ${i} 2 + a } diff --git a/tests/run-with-compiler/quote-run-staged-interpreter.scala b/tests/run-with-compiler/quote-run-staged-interpreter.scala index 59745f099865..c72a7ca91c54 100644 --- a/tests/run-with-compiler/quote-run-staged-interpreter.scala +++ b/tests/run-with-compiler/quote-run-staged-interpreter.scala @@ -11,7 +11,7 @@ enum Exp { object Test { import Exp._ - def compile(e: Exp, env: Map[String, Expr[Int]], keepLets: Boolean): Expr[Int] = { + def compile(e: Exp, env: Map[String, Expr[Int]], keepLets: Boolean) given QuoteContext: Expr[Int] = { def compileImpl(e: Exp, env: Map[String, Expr[Int]]): Expr[Int] = e match { case Num(n) => n case Plus(e1, e2) => '{${compileImpl(e1, env)} + ${compileImpl(e2, env)}} @@ -31,27 +31,25 @@ object Test { val exp = Plus(Plus(Num(2), Var("x")), Num(4)) val letExp = Let("x", Num(3), exp) - val res1 = '{ (x: Int) => ${compile(exp, Map("x" -> 'x), false)} } + def res1 given QuoteContext = '{ (x: Int) => ${compile(exp, Map("x" -> 'x), false)} } println(withQuoteContext(res1.show)) - val fn = run { - res1 - } + val fn = run(res1) println(fn(0)) println(fn(2)) println(fn(3)) println("---") - val res2 = compile(letExp, Map(), false) + def res2 given QuoteContext = compile(letExp, Map(), false) println(withQuoteContext(res2.show)) println(run(res2)) println("---") - val res3 = compile(letExp, Map(), true) + def res3 given QuoteContext = compile(letExp, Map(), true) println(withQuoteContext(res3.show)) println(run(res3)) } diff --git a/tests/run-with-compiler/quote-unrolled-foreach.scala b/tests/run-with-compiler/quote-unrolled-foreach.scala index 260c6ec7dd0d..427275730c5b 100644 --- a/tests/run-with-compiler/quote-unrolled-foreach.scala +++ b/tests/run-with-compiler/quote-unrolled-foreach.scala @@ -73,7 +73,7 @@ object Test { } } - def foreach2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]): Expr[Unit] = '{ + def foreach2(arrRef: Expr[Array[Int]], f: Expr[Int => Unit]) given QuoteContext: Expr[Unit] = '{ val size = ($arrRef).length var i = 0 while (i < size) { @@ -107,7 +107,7 @@ object Test { } } - def foreach4(arrRef: Expr[Array[Int]], f: Expr[Int => Unit], unrollSize: Int): Expr[Unit] = '{ + def foreach4(arrRef: Expr[Array[Int]], f: Expr[Int => Unit], unrollSize: Int) given QuoteContext: Expr[Unit] = '{ val size = ($arrRef).length var i = 0 if (size % ${unrollSize} != 0) throw new Exception("...") // for simplicity of the implementation @@ -118,7 +118,7 @@ object Test { } implicit object ArrayIntIsLiftable extends Liftable[Array[Int]] { - override def toExpr(x: Array[Int]): Expr[Array[Int]] = '{ + override def toExpr(x: Array[Int]) given QuoteContext: Expr[Array[Int]] = '{ val array = new Array[Int](${x.length}) ${ foreachInRange(0, x.length)(i => '{ array(${i}) = ${x(i)}}) } array diff --git a/tests/run-with-compiler/shonan-hmm-simple.scala b/tests/run-with-compiler/shonan-hmm-simple.scala index 9737d1ed1829..6cfc6ea421ed 100644 --- a/tests/run-with-compiler/shonan-hmm-simple.scala +++ b/tests/run-with-compiler/shonan-hmm-simple.scala @@ -34,16 +34,16 @@ class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] { } sealed trait PV[T] { - def expr(implicit l: Liftable[T]): Expr[T] + def expr given Liftable[T], QuoteContext: Expr[T] } case class Sta[T](x: T) extends PV[T] { - def expr(implicit l: Liftable[T]): Expr[T] = x + def expr given Liftable[T], QuoteContext: Expr[T] = x } case class Dyn[T](x: Expr[T]) extends PV[T] { - def expr(implicit l: Liftable[T]): Expr[T] = x + def expr given Liftable[T], QuoteContext: Expr[T] = x } -class RingPV[U: Liftable](u: Ring[U], eu: Ring[Expr[U]]) extends Ring[PV[U]] { +class RingPV[U: Liftable](u: Ring[U], eu: Ring[Expr[U]]) given QuoteContext extends Ring[PV[U]] { val zero: PV[U] = Sta(u.zero) val one: PV[U] = Sta(u.one) val add = (x: PV[U], y: PV[U]) => (x, y) match { @@ -72,7 +72,7 @@ case class Complex[T](re: T, im: T) object Complex { implicit def isLiftable[T: Type: Liftable]: Liftable[Complex[T]] = new Liftable[Complex[T]] { - def toExpr(comp: Complex[T]): Expr[Complex[T]] = '{Complex(${comp.re}, ${comp.im})} + def toExpr(comp: Complex[T]) given QuoteContext: Expr[Complex[T]] = '{Complex(${comp.re}, ${comp.im})} } } @@ -141,8 +141,8 @@ object Test { println(res2) println() - val blasStaticIntExpr = new Blas1(new RingIntExpr, new StaticVecOps) - val resCode1 = blasStaticIntExpr.dot( + def blasStaticIntExpr given QuoteContext = new Blas1(new RingIntExpr, new StaticVecOps) + def resCode1 given QuoteContext = blasStaticIntExpr.dot( vec1.map(_.toExpr), vec2.map(_.toExpr) ) @@ -165,8 +165,8 @@ object Test { println(run(resCode2).apply(arr1, arr2)) println() - val blasStaticIntPVExpr = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) - val resCode3 = blasStaticIntPVExpr.dot( + def blasStaticIntPVExpr given QuoteContext = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) + def resCode3 given QuoteContext = blasStaticIntPVExpr.dot( vec1.map(i => Dyn(i)), vec2.map(i => Sta(i)) ).expr @@ -174,8 +174,8 @@ object Test { println(run(resCode3)) println() - val blasExprIntPVExpr = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) - val resCode4: Expr[Array[Int] => Int] = '{ + def blasExprIntPVExpr given QuoteContext = new Blas1(new RingPV[Int](new RingInt, new RingIntExpr), new StaticVecOps) + def resCode4 given QuoteContext: Expr[Array[Int] => Int] = '{ arr => if (arr.length != ${vec2.size}) throw new Exception("...") ${ @@ -191,8 +191,8 @@ object Test { println() import Complex.isLiftable - val blasExprComplexPVInt = new Blas1[Int, Complex[PV[Int]]](new RingComplex(new RingPV[Int](new RingInt, new RingIntExpr)), new StaticVecOps) - val resCode5: Expr[Array[Complex[Int]] => Complex[Int]] = '{ + def blasExprComplexPVInt given QuoteContext = new Blas1[Int, Complex[PV[Int]]](new RingComplex(new RingPV[Int](new RingInt, new RingIntExpr)), new StaticVecOps) + def resCode5 given QuoteContext: Expr[Array[Complex[Int]] => Complex[Int]] = '{ arr => if (arr.length != ${cmpxVec2.size}) throw new Exception("...") ${ @@ -207,12 +207,12 @@ object Test { println(run(resCode5).apply(cmpxArr1)) println() - val RingPVInt = new RingPV[Int](new RingInt, new RingIntExpr) + def RingPVInt given QuoteContext = new RingPV[Int](new RingInt, new RingIntExpr) // Staged loop of dot product on vectors of Int or Expr[Int] - val dotIntOptExpr = new Blas1(RingPVInt, new StaticVecOps).dot + def dotIntOptExpr given QuoteContext = new Blas1(RingPVInt, new StaticVecOps).dot // will generate the code '{ ((arr: scala.Array[scala.Int]) => arr.apply(1).+(arr.apply(3))) } val staticVec = Vec[Int, PV[Int]](5, i => Sta((i % 2))) - val code = '{(arr: Array[Int]) => ${dotIntOptExpr(Vec(5, i => Dyn('{arr(${i})})), staticVec).expr} } + def code given QuoteContext = '{(arr: Array[Int]) => ${dotIntOptExpr(Vec(5, i => Dyn('{arr(${i})})), staticVec).expr} } println(withQuoteContext(code.show)) println() } diff --git a/tests/run-with-compiler/shonan-hmm/Complex.scala b/tests/run-with-compiler/shonan-hmm/Complex.scala index b73e0bbfade0..43d7776f3e83 100644 --- a/tests/run-with-compiler/shonan-hmm/Complex.scala +++ b/tests/run-with-compiler/shonan-hmm/Complex.scala @@ -5,11 +5,11 @@ 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]): Expr[Complex[T]] = '{ Complex(${c.re.toExpr}, ${c.im.toExpr}) } + def toExpr(c: Complex[T]) given QuoteContext: Expr[Complex[T]] = '{ Complex(${c.re.toExpr}, ${c.im.toExpr}) } } - def of_complex_expr(x: Expr[Complex[Int]]): Complex[Expr[Int]] = Complex('{$x.re}, '{$x.im}) - def of_expr_complex(x: Complex[Expr[Int]]): Expr[Complex[Int]] = '{Complex(${x.re}, ${x.im})} + def of_complex_expr(x: Expr[Complex[Int]]) given QuoteContext: Complex[Expr[Int]] = Complex('{$x.re}, '{$x.im}) + def of_expr_complex(x: Complex[Expr[Int]]) given QuoteContext: Expr[Complex[Int]] = '{Complex(${x.re}, ${x.im})} } \ No newline at end of file diff --git a/tests/run-with-compiler/shonan-hmm/Lifters.scala b/tests/run-with-compiler/shonan-hmm/Lifters.scala index 56d8eb0a4e93..199da46f1a96 100644 --- a/tests/run-with-compiler/shonan-hmm/Lifters.scala +++ b/tests/run-with-compiler/shonan-hmm/Lifters.scala @@ -6,21 +6,25 @@ import scala.quoted._ import scala.quoted.autolift._ object Lifters { - implicit def LiftedClassTag[T: Type](implicit ct: ClassTag[T]): Expr[ClassTag[T]] = { - '{ ClassTag(${ct.runtimeClass })} + implicit def LiftedClassTag[T: Type: ClassTag] given QuoteContext: Expr[ClassTag[T]] = { + '{ ClassTag(${the[ClassTag[T]].runtimeClass })} } - implicit def ArrayIsLiftable[T : Type: ClassTag](implicit l: Liftable[T]): Liftable[Array[T]] = arr => '{ - val array = new Array[T](${arr.length})(${implicitly[Expr[ClassTag[T]]]}) - ${initArray(arr, 'array)} + implicit def ArrayIsLiftable[T : Type: ClassTag](implicit l: Liftable[T]): Liftable[Array[T]] = new Liftable[Array[T]] { + def toExpr(x: Array[T]) given QuoteContext: Expr[Array[T]] = '{ + val array = new Array[T](${x.length})(${implicitly[Expr[ClassTag[T]]]}) + ${initArray(x, 'array)} + } } - implicit def IntArrayIsLiftable: Liftable[Array[Int]] = arr => '{ - val array = new Array[Int](${arr.length}) - ${initArray(arr, 'array)} + implicit def IntArrayIsLiftable: Liftable[Array[Int]] = new Liftable[Array[Int]] { + def toExpr(x: Array[Int]) given QuoteContext: Expr[Array[Int]] = '{ + val array = new Array[Int](${x.length}) + ${initArray(x, 'array)} + } } - private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]]): Expr[Array[T]] = { + private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]]) given QuoteContext: Expr[Array[T]] = { UnrolledExpr.block( arr.zipWithIndex.map { case (x, i) => '{ $array(${i}) = ${x} } diff --git a/tests/run-with-compiler/shonan-hmm/MVmult.scala b/tests/run-with-compiler/shonan-hmm/MVmult.scala index 72d35144acf0..eb08a5f846b8 100644 --- a/tests/run-with-compiler/shonan-hmm/MVmult.scala +++ b/tests/run-with-compiler/shonan-hmm/MVmult.scala @@ -22,7 +22,7 @@ object MVmult { MV.mvmult(vout_, a_, v_) } - def mvmult_c: Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = '{ + def mvmult_c given QuoteContext: Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = '{ (vout, a, v) => { val n = vout.length val m = v.length @@ -37,7 +37,7 @@ object MVmult { } } - def mvmult_mc(n: Int, m: Int): Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = { + def mvmult_mc(n: Int, m: Int) given QuoteContext: Expr[(Array[Int], Array[Array[Int]], Array[Int]) => Unit] = { val MV = new MVmult[Int, Expr[Int], Expr[Unit]](RingIntExpr, new VecRStaDim(RingIntExpr)) '{ (vout, a, v) => { @@ -54,7 +54,7 @@ object MVmult { } } - def mvmult_ac(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_ac(a: Array[Array[Int]]) given QuoteContext: Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ val arr = ${a} @@ -65,7 +65,7 @@ object MVmult { } } - def mvmult_opt(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_opt(a: Array[Array[Int]]) given QuoteContext: Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ val arr = ${a} @@ -76,7 +76,7 @@ object MVmult { } } - def mvmult_roll(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_roll(a: Array[Array[Int]]) given QuoteContext: Expr[(Array[Int], Array[Int]) => Unit] = { import Lifters._ '{ val arr = ${a} @@ -87,19 +87,19 @@ object MVmult { } } - def mvmult_let1(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_let1(a: Array[Array[Int]]) given QuoteContext: Expr[(Array[Int], Array[Int]) => Unit] = { val (n, m, a2) = amatCopy(a, copy_row1) mvmult_abs0(new RingIntOPExpr, new VecRStaOptDynInt(new RingIntPExpr))(n, m, a2) } - def mvmult_let(a: Array[Array[Int]]): Expr[(Array[Int], Array[Int]) => Unit] = { + def mvmult_let(a: Array[Array[Int]]) given QuoteContext: Expr[(Array[Int], Array[Int]) => Unit] = { initRows(a) { rows => val (n, m, a2) = amat2(a, rows) mvmult_abs0(new RingIntOPExpr, new VecRStaOptDynInt(new RingIntPExpr))(n, m, a2) } } - def initRows[T: Type](a: Array[Array[Int]])(cont: Array[Expr[Array[Int]]] => Expr[T]): Expr[T] = { + def initRows[T: Type](a: Array[Array[Int]])(cont: Array[Expr[Array[Int]]] => Expr[T]) given QuoteContext: Expr[T] = { import Lifters._ def loop(i: Int, acc: List[Expr[Array[Int]]]): Expr[T] = { if (i >= a.length) cont(acc.toArray.reverse) @@ -114,7 +114,7 @@ object MVmult { loop(0, Nil) } - def amat1(a: Array[Array[Int]], aa: Expr[Array[Array[Int]]]): (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { + def amat1(a: Array[Array[Int]], aa: Expr[Array[Array[Int]]]) given QuoteContext: (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { val n = a.length val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { @@ -125,7 +125,7 @@ object MVmult { (n, m, vec) } - def amat2(a: Array[Array[Int]], refs: Array[Expr[Array[Int]]]): (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { + def amat2(a: Array[Array[Int]], refs: Array[Expr[Array[Int]]]) given QuoteContext: (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { val n = a.length val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { @@ -135,7 +135,7 @@ object MVmult { (n, m, vec) } - def amatCopy(a: Array[Array[Int]], copyRow: Array[Int] => (Expr[Int] => Expr[Int])): (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { + def amatCopy(a: Array[Array[Int]], copyRow: Array[Int] => (Expr[Int] => Expr[Int])) given QuoteContext: (Int, Int, Vec[PV[Int], Vec[PV[Int], PV[Int]]]) = { val n = a.length val m = a(0).length val vec: Vec[PV[Int], Vec[PV[Int], PV[Int]]] = Vec(Sta(n), i => Vec(Sta(m), j => (i, j) match { @@ -148,7 +148,7 @@ object MVmult { (n, m, vec) } - def copy_row1: Array[Int] => (Expr[Int] => Expr[Int]) = v => { + def copy_row1 given QuoteContext: Array[Int] => (Expr[Int] => Expr[Int]) = v => { import Lifters._ val arr = v i => '{ ($arr).apply($i) } @@ -160,7 +160,7 @@ object MVmult { i => '{ ($arr).apply($i) } } - private def mvmult_abs0(ring: Ring[PV[Int]], vecOp: VecROp[PV[Int], PV[Int], Expr[Unit]])(n: Int, m: Int, a: Vec[PV[Int], Vec[PV[Int], PV[Int]]]): Expr[(Array[Int], Array[Int]) => Unit] = { + private def mvmult_abs0(ring: Ring[PV[Int]], vecOp: VecROp[PV[Int], PV[Int], Expr[Unit]])(n: Int, m: Int, a: Vec[PV[Int], Vec[PV[Int], PV[Int]]]) given QuoteContext: Expr[(Array[Int], Array[Int]) => Unit] = { '{ (vout, v) => { if (${n} != vout.length) throw new IndexOutOfBoundsException(${n.toString}) diff --git a/tests/run-with-compiler/shonan-hmm/PV.scala b/tests/run-with-compiler/shonan-hmm/PV.scala index d33cb7a45333..3247209e172c 100644 --- a/tests/run-with-compiler/shonan-hmm/PV.scala +++ b/tests/run-with-compiler/shonan-hmm/PV.scala @@ -8,9 +8,9 @@ case class Sta[T](x: T) extends PV[T] case class Dyn[T](x: Expr[T]) extends PV[T] object Dyns { - def dyn[T: Liftable](pv: PV[T]): Expr[T] = pv match { + def dyn[T: Liftable](pv: PV[T]) given QuoteContext: Expr[T] = pv match { case Sta(x) => x.toExpr case Dyn(x) => x } - val dyni: PV[Int] => Expr[Int] = dyn[Int] + def dyni given QuoteContext: PV[Int] => Expr[Int] = dyn[Int] } diff --git a/tests/run-with-compiler/shonan-hmm/Ring.scala b/tests/run-with-compiler/shonan-hmm/Ring.scala index 3763017d8424..53447fe7ad13 100644 --- a/tests/run-with-compiler/shonan-hmm/Ring.scala +++ b/tests/run-with-compiler/shonan-hmm/Ring.scala @@ -43,7 +43,7 @@ case class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] { override def toString(): String = s"RingComplex($u)" } -case class RingPV[U: Liftable](staRing: Ring[U], dynRing: Ring[Expr[U]]) extends Ring[PV[U]] { +case class RingPV[U: Liftable](staRing: Ring[U], dynRing: Ring[Expr[U]]) given QuoteContext extends Ring[PV[U]] { type T = PV[U] val dyn = Dyns.dyn[U] @@ -66,9 +66,9 @@ case class RingPV[U: Liftable](staRing: Ring[U], dynRing: Ring[Expr[U]]) extends } } -class RingIntPExpr extends RingPV(RingInt, RingIntExpr) +class RingIntPExpr given QuoteContext extends RingPV(RingInt, RingIntExpr) -class RingIntOPExpr extends RingIntPExpr { +class RingIntOPExpr given QuoteContext extends RingIntPExpr { override def add = (x: PV[Int], y: PV[Int]) => (x, y) match { case (Sta(0), y) => y case (x, Sta(0)) => x diff --git a/tests/run-with-compiler/shonan-hmm/VecROp.scala b/tests/run-with-compiler/shonan-hmm/VecROp.scala index 2be017b6385e..584e3f202e26 100644 --- a/tests/run-with-compiler/shonan-hmm/VecROp.scala +++ b/tests/run-with-compiler/shonan-hmm/VecROp.scala @@ -46,7 +46,7 @@ class VecRStaDim[T: Type](r: Ring[T]) extends VecROp[Int, T, Expr[Unit]] { override def toString(): String = s"VecRStaDim($r)" } -class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]]) extends VecROp[PV[Int], PV[T], Expr[Unit]] { +class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]]) given QuoteContext extends VecROp[PV[Int], PV[T], Expr[Unit]] { val VSta: VecROp[Int, PV[T], Expr[Unit]] = new VecRStaDim(r) val VDyn = new VecRDyn val dyn = Dyns.dyn[T] @@ -74,7 +74,7 @@ object VecRStaOptDynInt { val threshold = 3 } -class VecRStaOptDynInt(r: Ring[PV[Int]]) extends VecRStaDyn(r) { +class VecRStaOptDynInt(r: Ring[PV[Int]]) given QuoteContext extends VecRStaDyn(r) { val M: VecROp[PV[Int], PV[Int], Expr[Unit]] = new VecRStaDyn(r) override def reduce: ((PV[Int], PV[Int]) => PV[Int], PV[Int], Vec[PV[Int], PV[Int]]) => PV[Int] = (plus, zero, vec) => vec match { diff --git a/tests/run-with-compiler/shonan-hmm/Vmults.scala b/tests/run-with-compiler/shonan-hmm/Vmults.scala index 14837e8b3da9..a1709b5edf3e 100644 --- a/tests/run-with-compiler/shonan-hmm/Vmults.scala +++ b/tests/run-with-compiler/shonan-hmm/Vmults.scala @@ -19,7 +19,7 @@ object Vmults { V.vmult(vout_, v1_, v2_) } - def vmultCA: Expr[(Array[Complex[Int]], Array[Complex[Int]], Array[Complex[Int]]) => Unit] = '{ + def vmultCA given QuoteContext: Expr[(Array[Complex[Int]], Array[Complex[Int]], Array[Complex[Int]]) => Unit] = '{ (vout, v1, v2) => { val n = vout.length ${ diff --git a/tests/run-with-compiler/staged-tuples/StagedTuple.scala b/tests/run-with-compiler/staged-tuples/StagedTuple.scala index 0fbd68cad1e5..3bfd65528d4a 100644 --- a/tests/run-with-compiler/staged-tuples/StagedTuple.scala +++ b/tests/run-with-compiler/staged-tuples/StagedTuple.scala @@ -12,7 +12,7 @@ object StagedTuple { private final val specialize = true - def toArrayStaged(tup: Expr[Tuple], size: Option[Int]): Expr[Array[Object]] = { + def toArrayStaged(tup: Expr[Tuple], size: Option[Int]) given QuoteContext: Expr[Array[Object]] = { if (!specialize) '{dynamicToArray($tup)} else size match { case Some(0) => @@ -68,7 +68,7 @@ object StagedTuple { } } - def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int]): Expr[Res] = { + def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int]) given QuoteContext: Expr[Res] = { val res = if (!specialize) '{dynamicSize($tup)} else size match { @@ -101,7 +101,7 @@ object StagedTuple { } } - def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int]): Expr[Tail[Tup]] = { + def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int]) given QuoteContext: Expr[Tail[Tup]] = { if (!specialize) '{dynamicTail[Tup]($tup)} else { val res = size match { @@ -183,7 +183,7 @@ object StagedTuple { } } - def consStaged[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int]): Expr[H *: T] = + def consStaged[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int]) given QuoteContext: Expr[H *: T] = if (!specialize) '{dynamicCons[H, T]($x, $self)} else { val res = tailSize match { @@ -205,7 +205,7 @@ object StagedTuple { res.as[H *: T] } - def concatStaged[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int]): Expr[Concat[Self, That]] = { + def concatStaged[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int]) given QuoteContext: Expr[Concat[Self, That]] = { if (!specialize) '{dynamicConcat[Self, That]($self, $that)} else { def genericConcat(xs: Expr[Tuple], ys: Expr[Tuple]): Expr[Tuple] = diff --git a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala index 3210112f7c51..befb0542a3a1 100644 --- a/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala +++ b/tests/run-with-compiler/tasty-extractors-constants-2/quoted_1.scala @@ -1,7 +1,6 @@ import scala.quoted._ import scala.quoted.autolift._ -import scala.tasty._ import scala.tasty.util._ object Macros { diff --git a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala index 9717f7c74546..7a3ccb9f3cde 100644 --- a/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala @@ -1,7 +1,5 @@ import scala.quoted._ -import scala.tasty._ - object Macros { inline def let[T](rhs: T)(body: => T => Unit): Unit =