diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index 570a83fb800e..7db054b3ca84 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -1444,7 +1444,14 @@ trait Printers case Type.SymRef(sym, prefix) => prefix match { - case Types.EmptyPrefix() => + case Type.ThisType(Types.EmptyPackage() | Types.RootPackage()) => + case NoPrefix() => + if (sym.owner.flags.is(Flags.Package)) { + // TODO should these be in the prefix? These are at least `scala`, `java` and `scala.collection`. + val packagePath = sym.owner.fullName.stripPrefix("").stripPrefix("").stripPrefix(".") + if (packagePath != "") + this += packagePath += "." + } case IsType(prefix @ Type.SymRef(IsClassSymbol(_), _)) => printType(prefix) this += "#" @@ -1521,7 +1528,7 @@ trait Printers this += highlightTypeDef(".this", color) case Type.TypeRef(name, prefix) if name.endsWith("$") => prefix match { - case Types.EmptyPrefix() => + case NoPrefix() | Type.ThisType(Types.EmptyPackage() | Types.RootPackage()) => case _ => printTypeOrBound(prefix) this += "." @@ -1818,12 +1825,6 @@ trait Printers } } - object EmptyPrefix { - def unapply(tpe: TypeOrBounds)(implicit ctx: Context): Boolean = tpe match { - case NoPrefix() | Type.ThisType(Types.EmptyPackage() | Types.RootPackage()) => true - case _ => false - } - } } object PackageObject { diff --git a/tests/pos/simpleExtractors-1.decompiled b/tests/pos/simpleExtractors-1.decompiled index fe11840b562a..f79cf694d907 100644 --- a/tests/pos/simpleExtractors-1.decompiled +++ b/tests/pos/simpleExtractors-1.decompiled @@ -2,13 +2,13 @@ object Bar { def unapply(arg: scala.Any): scala.Option[scala.Any] = scala.Some.apply[scala.Any](arg) } object BarSeq { - def unapplySeq(arg: scala.Any): scala.Option[scala.Seq[scala.Any]] = scala.Some.apply[collection.immutable.List[scala.Any]](scala.List.apply[scala.Any](arg)) + def unapplySeq(arg: scala.Any): scala.Option[scala.Seq[scala.Any]] = scala.Some.apply[scala.collection.immutable.List[scala.Any]](scala.List.apply[scala.Any](arg)) } object Baz { def unapply[T](arg: T): scala.Option[T] = scala.Some.apply[T](arg) } object BazSeq { - def unapplySeq[T](arg: T): scala.Option[scala.Seq[T]] = scala.Some.apply[collection.immutable.List[T]](scala.List.apply[T](arg)) + def unapplySeq[T](arg: T): scala.Option[scala.Seq[T]] = scala.Some.apply[scala.collection.immutable.List[T]](scala.List.apply[T](arg)) } class Foo() { def bar(x: scala.Any): scala.Unit = x match { diff --git a/tests/pos/varargs-position.decompiled b/tests/pos/varargs-position.decompiled index d4459aa8d560..73d602b8ba5f 100644 --- a/tests/pos/varargs-position.decompiled +++ b/tests/pos/varargs-position.decompiled @@ -1,7 +1,7 @@ object varargspos { def g(a: scala.Int, x: scala.Int*): scala.Int = a.+(x.length) varargspos.g(1, 2, 3, 4) - val xs: collection.immutable.List[scala.Int] = scala.Nil.::[scala.Int](2).::[scala.Int](1) + val xs: scala.collection.immutable.List[scala.Int] = scala.Nil.::[scala.Int](2).::[scala.Int](1) val a: scala.Int = 8 val b: scala.Int = 7 varargspos.g(5, varargspos.xs: _*) @@ -9,4 +9,4 @@ object varargspos { varargspos.g(varargspos.a, varargspos.xs: _*) varargspos.g(varargspos.a, varargspos.b, 2, 3) varargspos.g(1) -} \ No newline at end of file +} diff --git a/tests/run-with-compiler/i3947.check b/tests/run-with-compiler/i3947.check index e9858aef278e..b8ff32ac2ad2 100644 --- a/tests/run-with-compiler/i3947.check +++ b/tests/run-with-compiler/i3947.check @@ -1,12 +1,12 @@ -scala.Predef.classOf[lang.Object].getCanonicalName() +scala.Predef.classOf[java.lang.Object].getCanonicalName() java.lang.Object -scala.Predef.classOf[lang.Object].getCanonicalName() +scala.Predef.classOf[java.lang.Object].getCanonicalName() java.lang.Object -scala.Predef.classOf[lang.Object].getCanonicalName() +scala.Predef.classOf[java.lang.Object].getCanonicalName() java.lang.Object -scala.Predef.classOf[lang.Object].getCanonicalName() +scala.Predef.classOf[java.lang.Object].getCanonicalName() java.lang.Object diff --git a/tests/run-with-compiler/i3947c.check b/tests/run-with-compiler/i3947c.check index ab30e827c9ab..516915a258a0 100644 --- a/tests/run-with-compiler/i3947c.check +++ b/tests/run-with-compiler/i3947c.check @@ -1,9 +1,9 @@ -scala.Predef.classOf[runtime.Null].getCanonicalName() +scala.Predef.classOf[scala.runtime.Null].getCanonicalName() scala.runtime.Null$ -scala.Predef.classOf[runtime.Nothing].getCanonicalName() +scala.Predef.classOf[scala.runtime.Nothing].getCanonicalName() scala.runtime.Nothing$ -scala.Predef.classOf[lang.String].getCanonicalName() +scala.Predef.classOf[java.lang.String].getCanonicalName() java.lang.String diff --git a/tests/run-with-compiler/i3947e.check b/tests/run-with-compiler/i3947e.check index 4483ce80170b..14cf4d2b1e8d 100644 --- a/tests/run-with-compiler/i3947e.check +++ b/tests/run-with-compiler/i3947e.check @@ -1,5 +1,5 @@ -scala.Predef.classOf[lang.Object].getCanonicalName() +scala.Predef.classOf[java.lang.Object].getCanonicalName() java.lang.Object scala.Predef.classOf[scala.Array[Foo]].getCanonicalName() diff --git a/tests/run-with-compiler/i3947f.check b/tests/run-with-compiler/i3947f.check index c1a2d2ab89fb..5ca81303272c 100644 --- a/tests/run-with-compiler/i3947f.check +++ b/tests/run-with-compiler/i3947f.check @@ -1,12 +1,12 @@ -scala.Predef.classOf[scala.Array[lang.Object]].getCanonicalName() +scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() java.lang.Object[] -scala.Predef.classOf[scala.Array[lang.Object]].getCanonicalName() +scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() java.lang.Object[] -scala.Predef.classOf[scala.Array[lang.Object]].getCanonicalName() +scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() java.lang.Object[] -scala.Predef.classOf[scala.Array[lang.Object]].getCanonicalName() +scala.Predef.classOf[scala.Array[java.lang.Object]].getCanonicalName() java.lang.Object[] diff --git a/tests/run-with-compiler/i5965.check b/tests/run-with-compiler/i5965.check index d0077520135f..f88ef8f53869 100644 --- a/tests/run-with-compiler/i5965.check +++ b/tests/run-with-compiler/i5965.check @@ -1,7 +1,7 @@ { - val y: collection.immutable.List[scala.Int] = scala.List.apply[scala.Int](1, 2, 3) + val y: scala.collection.immutable.List[scala.Int] = scala.List.apply[scala.Int](1, 2, 3) - (y: collection.immutable.List[scala.Int]) + (y: scala.collection.immutable.List[scala.Int]) } List(1, 2, 3) { @@ -11,8 +11,8 @@ List(1, 2, 3) } Some(4) { - val y: collection.immutable.Map[scala.Int, scala.Int] = scala.Predef.Map.apply[scala.Int, scala.Int](scala.Predef.ArrowAssoc[scala.Int](4).->[scala.Int](1)) + val y: scala.collection.immutable.Map[scala.Int, scala.Int] = scala.Predef.Map.apply[scala.Int, scala.Int](scala.Predef.ArrowAssoc[scala.Int](4).->[scala.Int](1)) - (y: collection.immutable.Map[scala.Int, scala.Int]) + (y: scala.collection.immutable.Map[scala.Int, scala.Int]) } Map(4 -> 1) diff --git a/tests/run-with-compiler/i5965b.check b/tests/run-with-compiler/i5965b.check index d0077520135f..f88ef8f53869 100644 --- a/tests/run-with-compiler/i5965b.check +++ b/tests/run-with-compiler/i5965b.check @@ -1,7 +1,7 @@ { - val y: collection.immutable.List[scala.Int] = scala.List.apply[scala.Int](1, 2, 3) + val y: scala.collection.immutable.List[scala.Int] = scala.List.apply[scala.Int](1, 2, 3) - (y: collection.immutable.List[scala.Int]) + (y: scala.collection.immutable.List[scala.Int]) } List(1, 2, 3) { @@ -11,8 +11,8 @@ List(1, 2, 3) } Some(4) { - val y: collection.immutable.Map[scala.Int, scala.Int] = scala.Predef.Map.apply[scala.Int, scala.Int](scala.Predef.ArrowAssoc[scala.Int](4).->[scala.Int](1)) + val y: scala.collection.immutable.Map[scala.Int, scala.Int] = scala.Predef.Map.apply[scala.Int, scala.Int](scala.Predef.ArrowAssoc[scala.Int](4).->[scala.Int](1)) - (y: collection.immutable.Map[scala.Int, scala.Int]) + (y: scala.collection.immutable.Map[scala.Int, scala.Int]) } Map(4 -> 1) diff --git a/tests/run-with-compiler/quote-owners-2.check b/tests/run-with-compiler/quote-owners-2.check index 1b03b435c991..847c2e2d84e1 100644 --- a/tests/run-with-compiler/quote-owners-2.check +++ b/tests/run-with-compiler/quote-owners-2.check @@ -1,11 +1,11 @@ 3 { def ff: scala.Int = { - val a: immutable.List[scala.Int] = { + val a: scala.collection.immutable.List[scala.Int] = { type T = scala.List[scala.Int] val b: T = scala.Nil.::[scala.Int](3) - (b: collection.immutable.List[scala.Int]) + (b: scala.collection.immutable.List[scala.Int]) } (a.head: scala.Int) diff --git a/tests/run/t4300.decompiled b/tests/run/t4300.decompiled index af603042de1a..5e4c21872830 100644 --- a/tests/run/t4300.decompiled +++ b/tests/run/t4300.decompiled @@ -23,4 +23,4 @@ object Test { b.g() b.h() } -} \ No newline at end of file +} diff --git a/tests/run/t8100.decompiled b/tests/run/t8100.decompiled index eb529cfeb106..6433606ca230 100644 --- a/tests/run/t8100.decompiled +++ b/tests/run/t8100.decompiled @@ -1,7 +1,7 @@ object Test { import scala.util.{Try} def main(args: scala.Array[scala.Predef.String]): scala.Unit = { - def stream: collection.immutable.Stream[scala.None.type] = scala.Stream.from(0).take(100000).map[scala.None.type, collection.immutable.Stream[scala.None.type]](((n: scala.Int) => scala.None))(collection.immutable.Stream.canBuildFrom[scala.None.type]) + def stream: scala.collection.immutable.Stream[scala.None.type] = scala.Stream.from(0).take(100000).map[scala.None.type, scala.collection.immutable.Stream[scala.None.type]](((n: scala.Int) => scala.None))(scala.collection.immutable.Stream.canBuildFrom[scala.None.type]) scala.Predef.println(scala.util.Try.apply[scala.Int](stream.flatten[scala.Nothing](((xo: scala.None.type) => scala.Option.option2Iterable[scala.Nothing](xo))).length)) } } diff --git a/tests/run/t889.decompiled b/tests/run/t889.decompiled index f2a863bd13ea..c82bde8ced14 100644 --- a/tests/run/t889.decompiled +++ b/tests/run/t889.decompiled @@ -1,5 +1,5 @@ object Test extends dotty.runtime.LegacyApp { - val a: collection.immutable.List[java.lang.String] = scala.List.apply[java.lang.String]("a") + val a: scala.collection.immutable.List[java.lang.String] = scala.List.apply[java.lang.String]("a") Test.a match { case scala.Seq("a", "b", rest: _*) => scala.Predef.println("a, b, ".+(rest)) diff --git a/tests/run/tasty-dealias.check b/tests/run/tasty-dealias.check index aa36eb4aae4c..757995b27b95 100644 --- a/tests/run/tasty-dealias.check +++ b/tests/run/tasty-dealias.check @@ -1,4 +1,4 @@ -lang.String -lang.String -immutable.List[A] -immutable.List[scala.Int] +java.lang.String +java.lang.String +scala.collection.immutable.List[A] +scala.collection.immutable.List[scala.Int] diff --git a/tests/run/tasty-typeof.check b/tests/run/tasty-typeof.check index 86fa6752a39e..3c96462a1ce1 100644 --- a/tests/run/tasty-typeof.check +++ b/tests/run/tasty-typeof.check @@ -1,3 +1,3 @@ -collection.immutable.List[scala.Int] +scala.collection.immutable.List[scala.Int] Macros Macros