From 75398c1c571be27bbd59bbda33380c7427016109 Mon Sep 17 00:00:00 2001 From: schinz Date: Thu, 24 Mar 2005 07:01:25 +0000 Subject: - improved toString method --- sources/scala/runtime/types/ScalaClassType.java | 24 +++++++++++++----------- sources/scala/runtime/types/TypeConstructor.java | 20 ++++++++++++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/sources/scala/runtime/types/ScalaClassType.java b/sources/scala/runtime/types/ScalaClassType.java index c338f17079..b999f1bcfb 100644 --- a/sources/scala/runtime/types/ScalaClassType.java +++ b/sources/scala/runtime/types/ScalaClassType.java @@ -131,21 +131,23 @@ public class ScalaClassType extends ClassType { public String toString() { StringBuffer buf = new StringBuffer(); - if (constr.outer != null) - buf.append(constr.outer).append("."); int firstM = constr.zCount; int firstP = firstM + constr.mCount; - buf.append(constr).append("["); - for (int i = 0; i < inst.length; ++i) { - if (i > 0) buf.append(", "); - if (i >= firstP) - buf.append('+'); - else if (i >= firstM) - buf.append('-'); - buf.append(inst[i]); + buf.append(constr); + if (inst.length > 0) { + buf.append("["); + for (int i = 0; i < inst.length; ++i) { + if (i > 0) buf.append(", "); + if (i >= firstP) + buf.append('+'); + else if (i >= firstM) + buf.append('-'); + buf.append(inst[i]); + } + buf.append("]"); } - return buf.append("]").toString(); + return buf.toString(); } public int hashCode() { diff --git a/sources/scala/runtime/types/TypeConstructor.java b/sources/scala/runtime/types/TypeConstructor.java index 83bbd93460..50029ed49d 100644 --- a/sources/scala/runtime/types/TypeConstructor.java +++ b/sources/scala/runtime/types/TypeConstructor.java @@ -27,12 +27,11 @@ public class TypeConstructor implements java.io.Serializable { public final static TypeConstructor[] EMPTY_ARRAY = new TypeConstructor[0]; + public final static Object FUNCTION_OUTER = new Object(); + /** Java class corresponding to this constructor. */ public Class clazz; - /** Enclosing class for this type constructor */ - public final Object outer; - /** * Number of invariant (z), contravariant (m) and covariant (p) * type arguments. @@ -47,7 +46,8 @@ public class TypeConstructor implements java.io.Serializable { /** * Indication of triviality: a constructor is trivial iff it has - * no enclosing class, and no type arguments. + * no enclosing class, and no type arguments. It is strongly + * trivial if all its ancestors, itself included, are trivial. */ public final boolean isTrivial; public final boolean isStronglyTrivial; @@ -61,13 +61,16 @@ public class TypeConstructor implements java.io.Serializable { * l1 n1 p1,0 o1,0 p1,1 o1,1 ... l2 n2 p2,0 o2,0 ... * * where all l, n, p and o are integers. ni gives the number of - * additional entries to add to the ancestors of the super-class + * additional entries to add to the ancestors of the first parent * at level li. pi gives the index of the parent in which to pick * this additional entry, and oi gives the offset of this entry in * the parent's ancestors. */ public final int[] ancestorCode; + /** Enclosing class for this type constructor */ + private final Object outer; + private final InstantiationMap instMapModule = new InstantiationMap(); private final AtomicReference/**/ instances = new AtomicReference(IOMap.EMPTY); @@ -105,7 +108,12 @@ public class TypeConstructor implements java.io.Serializable { } public String toString() { - return clazz.getName(); + if (outer == null) + return clazz.getName(); + else if (outer == FUNCTION_OUTER) + return "." + clazz.getName(); + else + return outer.toString() + "." + clazz.getName(); } public ScalaClassType getInstantiation(Type[] args) { -- cgit v1.2.3