diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 654da8141848..d042966bdc30 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -239,11 +239,10 @@ class ReifyQuotes extends MacroTransform { meth.appliedTo(pickledQuoteStrings, splicesList) } - if (splices.nonEmpty) pickleAsTasty() - else if (isType) { + if (isType) { def tag(tagName: String) = ref(defn.QuotedTypeModule).select(tagName.toTermName).appliedTo(qctx) - if (body.symbol.isPrimitiveValueClass) tag(s"${body.symbol.name}Tag") - else pickleAsTasty() + if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s"${body.symbol.name}Tag") + else pickleAsTasty().select(nme.apply).appliedTo(qctx) } else toValue(body) match { case Some(value) => pickleAsValue(value) diff --git a/library/src/scala/runtime/quoted/Unpickler.scala b/library/src/scala/runtime/quoted/Unpickler.scala index 00726b27e03e..47d3f675e78f 100644 --- a/library/src/scala/runtime/quoted/Unpickler.scala +++ b/library/src/scala/runtime/quoted/Unpickler.scala @@ -19,5 +19,6 @@ object Unpickler { /** Unpickle `repr` which represents a pickled `Type` tree, * replacing splice nodes with `args` */ - def unpickleType[T](repr: Pickled, args: Seq[Seq[Any] => Type[_]]): Type[T] = new TastyType[T](repr, args) + def unpickleType[T](repr: Pickled, args: Seq[Seq[Any] => Type[_]]): given QuoteContext => Type[T] = new TastyType[T](repr, args) + } diff --git a/tests/pos/i4414.scala b/tests/pos/i4414.scala index 2a2999ff34b7..61803f541caf 100644 --- a/tests/pos/i4414.scala +++ b/tests/pos/i4414.scala @@ -1,6 +1,7 @@ import scala.quoted._ object Test { + given as QuoteContext = ??? def a[A: Type](): Unit = { b[Expr[A]]() diff --git a/tests/run-with-compiler/i3947.check b/tests/run-with-compiler/i3947.check index b8ff32ac2ad2..9f746ed30dec 100644 --- a/tests/run-with-compiler/i3947.check +++ b/tests/run-with-compiler/i3947.check @@ -1,12 +1,8 @@ - scala.Predef.classOf[java.lang.Object].getCanonicalName() -java.lang.Object - scala.Predef.classOf[java.lang.Object].getCanonicalName() -java.lang.Object - scala.Predef.classOf[java.lang.Object].getCanonicalName() -java.lang.Object - scala.Predef.classOf[java.lang.Object].getCanonicalName() java.lang.Object +java.lang.Object +java.lang.Object +java.lang.Object diff --git a/tests/run-with-compiler/i3947.scala b/tests/run-with-compiler/i3947.scala index 4984b17deda6..35aa2334ccfe 100644 --- a/tests/run-with-compiler/i3947.scala +++ b/tests/run-with-compiler/i3947.scala @@ -3,21 +3,22 @@ import scala.quoted._ object Test { - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } // classOf[Object] - test(classOf[Object]) - test(classOf[Any]) - test(classOf[AnyRef]) - test(classOf[AnyVal]) + '{ + ${test(classOf[Object])} + ${test(classOf[Any])} + ${test(classOf[AnyRef])} + ${test(classOf[AnyVal])} + } } } diff --git a/tests/run-with-compiler/i3947c.check b/tests/run-with-compiler/i3947c.check index 516915a258a0..94b19056fd6d 100644 --- a/tests/run-with-compiler/i3947c.check +++ b/tests/run-with-compiler/i3947c.check @@ -1,9 +1,6 @@ - scala.Predef.classOf[scala.runtime.Null].getCanonicalName() -scala.runtime.Null$ - scala.Predef.classOf[scala.runtime.Nothing].getCanonicalName() -scala.runtime.Nothing$ - scala.Predef.classOf[java.lang.String].getCanonicalName() +scala.runtime.Null$ +scala.runtime.Nothing$ java.lang.String diff --git a/tests/run-with-compiler/i3947c.scala b/tests/run-with-compiler/i3947c.scala index 851b8c9ebe94..41fb74844d3a 100644 --- a/tests/run-with-compiler/i3947c.scala +++ b/tests/run-with-compiler/i3947c.scala @@ -2,21 +2,22 @@ import scala.quoted._ object Test { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } - test(classOf[Null]) - test(classOf[Nothing]) + '{ + ${test(classOf[Null])} + ${test(classOf[Nothing])} - test(classOf[String]) + ${test(classOf[String])} + } } } diff --git a/tests/run-with-compiler/i3947d.check b/tests/run-with-compiler/i3947d.check index 996b43603ef0..5cf1951c30bc 100644 --- a/tests/run-with-compiler/i3947d.check +++ b/tests/run-with-compiler/i3947d.check @@ -1,9 +1,6 @@ - scala.Predef.classOf[Foo].getCanonicalName() -Foo - scala.Predef.classOf[Foo#Bar].getCanonicalName() -Foo.Bar - scala.Predef.classOf[Foo.Baz].getCanonicalName() +Foo +Foo.Bar Foo.Baz diff --git a/tests/run-with-compiler/i3947d.scala b/tests/run-with-compiler/i3947d.scala index 91140bfd28ba..fc03dd7a6aa2 100644 --- a/tests/run-with-compiler/i3947d.scala +++ b/tests/run-with-compiler/i3947d.scala @@ -2,20 +2,21 @@ import scala.quoted._ object Test { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } - test(classOf[Foo]) - test(classOf[Foo#Bar]) - test(classOf[Foo.Baz]) + '{ + ${test(classOf[Foo])} + ${test(classOf[Foo#Bar])} + ${test(classOf[Foo.Baz])} + } } } diff --git a/tests/run-with-compiler/i3947d2.check b/tests/run-with-compiler/i3947d2.check index 10d70e743b15..359a98dce6d3 100644 --- a/tests/run-with-compiler/i3947d2.check +++ b/tests/run-with-compiler/i3947d2.check @@ -1,9 +1,6 @@ - scala.Predef.classOf[foo.Foo].getCanonicalName() -foo.Foo - scala.Predef.classOf[foo.Foo#Bar].getCanonicalName() -foo.Foo.Bar - scala.Predef.classOf[foo.Foo.Baz].getCanonicalName() +foo.Foo +foo.Foo.Bar foo.Foo.Baz diff --git a/tests/run-with-compiler/i3947d2.scala b/tests/run-with-compiler/i3947d2.scala index dd923aaad160..e28600389949 100644 --- a/tests/run-with-compiler/i3947d2.scala +++ b/tests/run-with-compiler/i3947d2.scala @@ -2,20 +2,21 @@ import scala.quoted._ object Test { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } - test(classOf[foo.Foo]) - test(classOf[foo.Foo#Bar]) - test(classOf[foo.Foo.Baz]) + '{ + ${test(classOf[foo.Foo])} + ${test(classOf[foo.Foo#Bar])} + ${test(classOf[foo.Foo.Baz])} + } } } diff --git a/tests/run-with-compiler/i3947e.check b/tests/run-with-compiler/i3947e.check index 14cf4d2b1e8d..21f67479ffde 100644 --- a/tests/run-with-compiler/i3947e.check +++ b/tests/run-with-compiler/i3947e.check @@ -1,9 +1,6 @@ - scala.Predef.classOf[java.lang.Object].getCanonicalName() -java.lang.Object - scala.Predef.classOf[scala.Array[Foo]].getCanonicalName() -Foo[] - scala.Predef.classOf[scala.Array[scala.Array[Foo]]].getCanonicalName() +java.lang.Object +Foo[] Foo[][] diff --git a/tests/run-with-compiler/i3947e.scala b/tests/run-with-compiler/i3947e.scala index 862a9a21a80e..f8d55b8da849 100644 --- a/tests/run-with-compiler/i3947e.scala +++ b/tests/run-with-compiler/i3947e.scala @@ -2,26 +2,27 @@ import scala.quoted._ object Test { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) + def main(args: Array[String]): Unit = run { - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } - // class Object - test(classOf[Array[_]]) + '{ + // class Object + ${test(classOf[Array[_]])} - // class Array[Foo] - test(classOf[Array[Foo]]) + // class Array[Foo] + ${test(classOf[Array[Foo]])} - // class Array[Array[Foo]] - test(classOf[Array[Array[Foo]]]) + // class Array[Array[Foo]] + ${test(classOf[Array[Array[Foo]]])} + } } } diff --git a/tests/run-with-compiler/i3947f.check b/tests/run-with-compiler/i3947f.check index 5ca81303272c..a0e9e810cb2b 100644 --- a/tests/run-with-compiler/i3947f.check +++ b/tests/run-with-compiler/i3947f.check @@ -1,12 +1,8 @@ - scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() -java.lang.Object[] - scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() -java.lang.Object[] - scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() -java.lang.Object[] - scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() java.lang.Object[] +java.lang.Object[] +java.lang.Object[] +java.lang.Object[] diff --git a/tests/run-with-compiler/i3947f.scala b/tests/run-with-compiler/i3947f.scala index a6930736c103..34a7dc25ada3 100644 --- a/tests/run-with-compiler/i3947f.scala +++ b/tests/run-with-compiler/i3947f.scala @@ -3,21 +3,23 @@ import scala.quoted._ object Test { - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) + + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } // class Array[Object] - test(classOf[Array[Any]]) - test(classOf[Array[AnyVal]]) - test(classOf[Array[AnyRef]]) - test(classOf[Array[Object]]) + '{ + ${test(classOf[Array[Any]])} + ${test(classOf[Array[AnyVal]])} + ${test(classOf[Array[AnyRef]])} + ${test(classOf[Array[Object]])} + } } } diff --git a/tests/run-with-compiler/i3947g.check b/tests/run-with-compiler/i3947g.check index 675a4d803573..b6aba473c309 100644 --- a/tests/run-with-compiler/i3947g.check +++ b/tests/run-with-compiler/i3947g.check @@ -1,12 +1,8 @@ - scala.Predef.classOf[scala.Array[scala.Boolean]].getCanonicalName() -boolean[] - scala.Predef.classOf[scala.Array[scala.Byte]].getCanonicalName() -byte[] - scala.Predef.classOf[scala.Array[scala.Char]].getCanonicalName() -char[] - scala.Predef.classOf[scala.Array[scala.Short]].getCanonicalName() +boolean[] +byte[] +char[] short[] diff --git a/tests/run-with-compiler/i3947g.scala b/tests/run-with-compiler/i3947g.scala index 05b8c033df11..4fa44fce8d32 100644 --- a/tests/run-with-compiler/i3947g.scala +++ b/tests/run-with-compiler/i3947g.scala @@ -2,22 +2,22 @@ import scala.quoted._ object Test { - - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } // primitive arrays - test(classOf[Array[Boolean]]) - test(classOf[Array[Byte]]) - test(classOf[Array[Char]]) - test(classOf[Array[Short]]) + '{ + ${test(classOf[Array[Boolean]])} + ${test(classOf[Array[Byte]])} + ${test(classOf[Array[Char]])} + ${test(classOf[Array[Short]])} + } } } diff --git a/tests/run-with-compiler/i3947i.check b/tests/run-with-compiler/i3947i.check index 112ef331cf08..5af90e617f3e 100644 --- a/tests/run-with-compiler/i3947i.check +++ b/tests/run-with-compiler/i3947i.check @@ -1,12 +1,8 @@ - scala.Predef.classOf[scala.Array[scala.Int]].getCanonicalName() -int[] - scala.Predef.classOf[scala.Array[scala.Long]].getCanonicalName() -long[] - scala.Predef.classOf[scala.Array[scala.Float]].getCanonicalName() -float[] - scala.Predef.classOf[scala.Array[scala.Double]].getCanonicalName() +int[] +long[] +float[] double[] diff --git a/tests/run-with-compiler/i3947i.scala b/tests/run-with-compiler/i3947i.scala index 113b2d492e4d..b0e66351aa2d 100644 --- a/tests/run-with-compiler/i3947i.scala +++ b/tests/run-with-compiler/i3947i.scala @@ -2,22 +2,23 @@ import scala.quoted._ object Test { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } // primitive arrays - test(classOf[Array[Int]]) - test(classOf[Array[Long]]) - test(classOf[Array[Float]]) - test(classOf[Array[Double]]) + '{ + ${test(classOf[Array[Int]])} + ${test(classOf[Array[Long]])} + ${test(classOf[Array[Float]])} + ${test(classOf[Array[Double]])} + } } } diff --git a/tests/run-with-compiler/i3947j.check b/tests/run-with-compiler/i3947j.check index 2ef0b42eedf6..257281b7a62d 100644 --- a/tests/run-with-compiler/i3947j.check +++ b/tests/run-with-compiler/i3947j.check @@ -1,6 +1,4 @@ - scala.Predef.classOf[scala.Array[scala.Array[scala.Int]]].getCanonicalName() -int[][] - scala.Predef.classOf[scala.Array[scala.Array[scala.Array[scala.Int]]]].getCanonicalName() +int[][] int[][][] diff --git a/tests/run-with-compiler/i3947j.scala b/tests/run-with-compiler/i3947j.scala index 37788b716a3e..260f04699df8 100644 --- a/tests/run-with-compiler/i3947j.scala +++ b/tests/run-with-compiler/i3947j.scala @@ -2,19 +2,20 @@ import scala.quoted._ object Test { + implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def main(args: Array[String]): Unit = { - implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader) - def test[T: Type](clazz: java.lang.Class[T]): Unit = run { + def main(args: Array[String]): Unit = run { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = clazz.toExpr val name = '{ ($lclazz).getCanonicalName } - println() println(name.show) '{ println($name) } } - test(classOf[Array[Array[Int]]]) - test(classOf[Array[Array[Array[Int]]]]) + '{ + ${test(classOf[Array[Array[Int]]])} + ${test(classOf[Array[Array[Array[Int]]]])} + } } }