summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-04 22:06:01 -0800
committerPaul Phillips <paulp@improving.org>2012-02-04 22:06:01 -0800
commitb265d014416f1c4c6b22d47b4be16b22499dc05f (patch)
tree3cbdab2cc10d567c50ec5c32655b2bca86cbdc65 /src
parent90039fcf18c28a0f89271e6b1fbb6dfd36e1d4ba (diff)
downloadscala-b265d014416f1c4c6b22d47b4be16b22499dc05f.tar.gz
scala-b265d014416f1c4c6b22d47b4be16b22499dc05f.tar.bz2
scala-b265d014416f1c4c6b22d47b4be16b22499dc05f.zip
Tweaking parent printing a little further.
Not too many Object/AnyRef parents, not too few.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/Definitions.scala19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala
index a06f2d07bf..2ca9c8bfd0 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/compiler/scala/reflect/internal/Definitions.scala
@@ -716,7 +716,16 @@ trait Definitions extends reflect.api.StandardDefinitions {
/** Remove references to class Object (other than the head) in a list of parents */
def removeLaterObjects(tps: List[Type]): List[Type] = tps match {
case Nil => Nil
- case x :: xs => x :: xs.filter(_.typeSymbol != ObjectClass)
+ case x :: xs => x :: xs.filterNot(_.typeSymbol == ObjectClass)
+ }
+ /** Remove all but one reference to class Object from a list of parents. */
+ def removeRedundantObjects(tps: List[Type]): List[Type] = tps match {
+ case Nil => Nil
+ case x :: xs =>
+ if (x.typeSymbol == ObjectClass)
+ x :: xs.filterNot(_.typeSymbol == ObjectClass)
+ else
+ x :: removeRedundantObjects(xs)
}
/** Order a list of types with non-trait classes before others. */
def classesFirst(tps: List[Type]): List[Type] = {
@@ -725,15 +734,15 @@ trait Definitions extends reflect.api.StandardDefinitions {
else classes ::: others
}
/** The following transformations applied to a list of parents.
- * If any parent is a class/trait, all parents which are Object
- * or an alias of it are discarded. Otherwise, all Objects other
- * the head of the list are discarded.
+ * If any parent is a class/trait, all parents which normalize to
+ * Object are discarded. Otherwise, all parents which normalize
+ * to Object except the first one found are discarded.
*/
def normalizedParents(parents: List[Type]): List[Type] = {
if (parents exists (t => (t.typeSymbol ne ObjectClass) && t.typeSymbol.isClass))
parents filterNot (_.typeSymbol eq ObjectClass)
else
- removeLaterObjects(parents)
+ removeRedundantObjects(parents)
}
def parentsString(parents: List[Type]) =
normalizedParents(parents) mkString " with "