summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Types.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-30 10:34:14 -0800
committerPaul Phillips <paulp@improving.org>2012-01-30 11:23:53 -0800
commit366fae9741283efc08edb32378f56a08417ff35a (patch)
treec129c104783e36b795904d8fefee6ce590c5e382 /src/compiler/scala/reflect/internal/Types.scala
parent84fd439fb1c2f08439e539aea4f9657c6768bc83 (diff)
downloadscala-366fae9741283efc08edb32378f56a08417ff35a.tar.gz
scala-366fae9741283efc08edb32378f56a08417ff35a.tar.bz2
scala-366fae9741283efc08edb32378f56a08417ff35a.zip
Print compound types legibly.
This one's about a million years overdue. Try this on for size, from the command line: printf ":power\nList(1).?.baseClasses.sigs >\n" | scala Also, a little more power mode refinement.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index fab10f7896..371fb8d585 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -1409,7 +1409,7 @@ trait Types extends api.Types { self: SymbolTable =>
// override def isNullable: Boolean =
// parents forall (p => p.isNullable && !p.typeSymbol.isAbstractType);
-
+
override def safeToString: String =
parents.mkString(" with ") +
(if (settings.debug.value || parents.isEmpty || (decls.elems ne null))
@@ -1750,6 +1750,19 @@ trait Types extends api.Types { self: SymbolTable =>
// override def isNonNull: Boolean = symbol == NonNullClass || super.isNonNull;
override def kind = "ClassInfoType"
+
+ override def safeToString =
+ if (settings.debug.value || decls.size > 1)
+ formattedToString
+ else
+ super.safeToString
+
+ /** A nicely formatted string with newlines and such.
+ */
+ def formattedToString: String =
+ parents.mkString("\n with ") +
+ (if (settings.debug.value || parents.isEmpty || (decls.elems ne null))
+ decls.mkString(" {\n ", "\n ", "\n}") else "")
}
object ClassInfoType extends ClassInfoTypeExtractor
@@ -2479,7 +2492,7 @@ trait Types extends api.Types { self: SymbolTable =>
*/
case class AntiPolyType(pre: Type, targs: List[Type]) extends Type {
override def safeToString =
- pre.toString + targs.mkString("(with type arguments ", ",", ")");
+ pre.toString + targs.mkString("(with type arguments ", ", ", ")");
override def memberType(sym: Symbol) = appliedType(pre.memberType(sym), targs)
// override def memberType(sym: Symbol) = pre.memberType(sym) match {
// case PolyType(tparams, restp) =>
@@ -3521,14 +3534,14 @@ trait Types extends api.Types { self: SymbolTable =>
}
override def toString = {
- val boundsStr = (
- if (loBounds.isEmpty && hiBounds.isEmpty) "[]"
- else {
- val lostr = if (loBounds.isEmpty) "" else loBounds map (_.safeToString) mkString("_>:(", ", ", ")")
- val histr = if (hiBounds.isEmpty) "" else hiBounds map (_.safeToString) mkString("_<:(", ", ", ")")
- List(lostr, histr) filterNot (_ == "") mkString ("[", " | ", "]")
- }
- )
+ val boundsStr = {
+ val lo = loBounds filterNot (_.typeSymbolDirect eq NothingClass)
+ val hi = hiBounds filterNot (_.typeSymbolDirect eq AnyClass)
+ val lostr = if (lo.isEmpty) Nil else List(lo.mkString(" >: (", ", ", ")"))
+ val histr = if (hi.isEmpty) Nil else List(hi.mkString(" <: (", ", ", ")"))
+
+ lostr ++ histr mkString ("[", " | ", "]")
+ }
if (inst eq NoType) boundsStr
else boundsStr + " _= " + inst.safeToString
}