summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2005-03-24 07:01:25 +0000
committerschinz <schinz@epfl.ch>2005-03-24 07:01:25 +0000
commit75398c1c571be27bbd59bbda33380c7427016109 (patch)
treeb26031becb4b36d5bcce7493a3055b8c05c90d42 /sources
parentd5dd90881087d6e6940f60a62e1d708670379ff1 (diff)
downloadscala-75398c1c571be27bbd59bbda33380c7427016109.tar.gz
scala-75398c1c571be27bbd59bbda33380c7427016109.tar.bz2
scala-75398c1c571be27bbd59bbda33380c7427016109.zip
- improved toString method
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/runtime/types/ScalaClassType.java24
-rw-r--r--sources/scala/runtime/types/TypeConstructor.java20
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/*<InstantiationMap.T>*/ 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 "<function>." + clazz.getName();
+ else
+ return outer.toString() + "." + clazz.getName();
}
public ScalaClassType getInstantiation(Type[] args) {