summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala9
-rw-r--r--test/files/run/t5537.check20
-rw-r--r--test/files/run/t5537.scala10
3 files changed, 38 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index ed1631fae5..0a9449226b 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -1118,7 +1118,14 @@ trait Types extends api.Types { self: SymbolTable =>
underlying.baseTypeSeq prepend this
}
override def isHigherKinded = false // singleton type classifies objects, thus must be kind *
- override def safeToString: String = prefixString + "type"
+ override def safeToString: String = {
+ // Avoiding printing Predef.type and scala.package.type as "type",
+ // since in all other cases we omit those prefixes.
+ val pre = underlying.typeSymbol.skipPackageObject
+ if (pre.isOmittablePrefix) pre.fullName + ".type"
+ else prefixString + "type"
+ }
+
/*
override def typeOfThis: Type = typeSymbol.typeOfThis
override def bounds: TypeBounds = TypeBounds(this, this)
diff --git a/test/files/run/t5537.check b/test/files/run/t5537.check
new file mode 100644
index 0000000000..68c3ebf2e2
--- /dev/null
+++ b/test/files/run/t5537.check
@@ -0,0 +1,20 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> List[Predef.type]()
+res0: List[scala.Predef.type] = List()
+
+scala> List[scala.`package`.type]()
+res1: List[scala.type] = List()
+
+scala> List[List.type]()
+res2: List[scala.collection.immutable.List.type] = List()
+
+scala> List[Set.type]()
+res3: List[Set.type] = List()
+
+scala>
+
+scala>
diff --git a/test/files/run/t5537.scala b/test/files/run/t5537.scala
new file mode 100644
index 0000000000..ae88dcc11f
--- /dev/null
+++ b/test/files/run/t5537.scala
@@ -0,0 +1,10 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+List[Predef.type]()
+List[scala.`package`.type]()
+List[List.type]()
+List[Set.type]()
+ """
+}