Skip to content

Print missing package prefixes #6113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions library/src/scala/tasty/reflect/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,11 @@ trait Printers
case Type.SymRef(sym, prefix) =>
prefix match {
case Types.EmptyPrefix() =>
if (sym.owner.flags.is(Flags.Package)) {
val packagePath = sym.owner.fullName.stripPrefix("<root>").stripPrefix("<empty>").stripPrefix(".")
if (packagePath != "")
this += packagePath += "."
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering inside the if, what is the value of prefix at runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a Types.EmptyPrefix() as the pattern matching indicates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case, it seems to me the type is ill-formed, the prefix is wrong -- or I misunderstood the invariant for TermRef. We can get this in to unblock other issues, but it would be nice to clarify the invariant about TermRef. /cc: @odersky .

case IsType(prefix @ Type.SymRef(IsClassSymbol(_), _)) =>
printType(prefix)
this += "#"
Expand Down
4 changes: 2 additions & 2 deletions tests/pos/simpleExtractors-1.decompiled
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/pos/varargs-position.decompiled
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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: _*)
varargspos.g(3, scala.Nil: _*)
varargspos.g(varargspos.a, varargspos.xs: _*)
varargspos.g(varargspos.a, varargspos.b, 2, 3)
varargspos.g(1)
}
}
8 changes: 4 additions & 4 deletions tests/run-with-compiler/i3947.check
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions tests/run-with-compiler/i3947c.check
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3947e.check
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
8 changes: 4 additions & 4 deletions tests/run-with-compiler/i3947f.check
Original file line number Diff line number Diff line change
@@ -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[]
8 changes: 4 additions & 4 deletions tests/run-with-compiler/i5965.check
Original file line number Diff line number Diff line change
@@ -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)
{
Expand All @@ -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)
8 changes: 4 additions & 4 deletions tests/run-with-compiler/i5965b.check
Original file line number Diff line number Diff line change
@@ -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)
{
Expand All @@ -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)
4 changes: 2 additions & 2 deletions tests/run-with-compiler/quote-owners-2.check
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/run/t4300.decompiled
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ object Test {
b.g()
b.h()
}
}
}
2 changes: 1 addition & 1 deletion tests/run/t8100.decompiled
Original file line number Diff line number Diff line change
@@ -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))
}
}
2 changes: 1 addition & 1 deletion tests/run/t889.decompiled
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
8 changes: 4 additions & 4 deletions tests/run/tasty-dealias.check
Original file line number Diff line number Diff line change
@@ -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]
2 changes: 1 addition & 1 deletion tests/run/tasty-typeof.check
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
collection.immutable.List[scala.Int]
scala.collection.immutable.List[scala.Int]
Macros
Macros