diff options
author | Paul Phillips <paulp@improving.org> | 2012-03-02 20:07:25 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-03-02 20:13:23 -0800 |
commit | d852612c3537f2e4506dd838c719d44a3031679d (patch) | |
tree | a56afe52a9a86f50e6fe0f83d225364997527f87 | |
parent | 43532f1192f1cf71989f7e78b7ee277b03806643 (diff) | |
download | scala-d852612c3537f2e4506dd838c719d44a3031679d.tar.gz scala-d852612c3537f2e4506dd838c719d44a3031679d.tar.bz2 scala-d852612c3537f2e4506dd838c719d44a3031679d.zip |
Fix for corner case in type printing.
Closes SI-5537.
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 9 | ||||
-rw-r--r-- | test/files/run/t5537.check | 20 | ||||
-rw-r--r-- | test/files/run/t5537.scala | 10 |
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]() + """ +} |