diff options
author | paltherr <paltherr@epfl.ch> | 2003-11-19 09:22:12 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-11-19 09:22:12 +0000 |
commit | 862f5badaa0d8e5761ad1de94366941f498239dd (patch) | |
tree | df635ce3e8885482bca851d37c1b0ae227dca7f9 /sources/scalac | |
parent | cf31deaa19e8aa39fea15bfedaf7d8870aa96aa6 (diff) | |
download | scala-862f5badaa0d8e5761ad1de94366941f498239dd.tar.gz scala-862f5badaa0d8e5761ad1de94366941f498239dd.tar.bz2 scala-862f5badaa0d8e5761ad1de94366941f498239dd.zip |
- Removed inner classes from RunTime
- Added some metadata to RunTime
- Adapted Primitives and ErasurePhase to the new metadata
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/backend/Primitives.java | 11 | ||||
-rw-r--r-- | sources/scalac/transformer/ErasurePhase.java | 28 |
2 files changed, 26 insertions, 13 deletions
diff --git a/sources/scalac/backend/Primitives.java b/sources/scalac/backend/Primitives.java index bf1b3de15b..33d420e90b 100644 --- a/sources/scalac/backend/Primitives.java +++ b/sources/scalac/backend/Primitives.java @@ -268,7 +268,7 @@ public class Primitives { this.BOX_FARRAY = getBoxArray(boxes, definitions.FLOAT_TYPE()); this.BOX_DARRAY = getBoxArray(boxes, definitions.DOUBLE_TYPE()); this.BOX_OARRAY = getBoxArray(boxes, definitions.JAVA_OBJECT_TYPE()); - this.BOX__ARRAY = getBoxValue(boxes, definitions.ANY_TYPE()); + this.BOX__ARRAY = getBoxArray(boxes, definitions.ANY_TYPE()); this.AS_UVALUE = getUniqueTerm(definitions.UNIT_CLASS, AS_UVALUE_N); this.AS_ZVALUE = getUniqueTerm(definitions.BOOLEAN_CLASS, AS_ZVALUE_N); this.AS_BVALUE = getUniqueTerm(definitions.DOUBLE_CLASS, AS_BVALUE_N); @@ -314,13 +314,14 @@ public class Primitives { private Symbol getBoxValue(Symbol[] alts, Type type) { for (int i = 0; i < alts.length; i++) { + Type result = alts[i].type().resultType(); switch (alts[i].type()) { - case MethodType(Symbol[] vparams, _): - if (vparams.length == 1 && vparams[0].type().equals(type)) - return alts[i]; + case PolyType(Symbol[] tparams, _): + result = result.subst(tparams, Symbol.info(tparams)); } + if (result.equals(type)) return alts[i]; } - throw Debug.abort("not found:" + BOX_N + "(" + Debug.show(type) + ")"); + throw Debug.abort("not found: def " +BOX_N+ "(" +type+ "): " +type); } private Symbol getBoxArray(Symbol[] alts, Type type) { diff --git a/sources/scalac/transformer/ErasurePhase.java b/sources/scalac/transformer/ErasurePhase.java index 87fddbf37e..37f4abc58e 100644 --- a/sources/scalac/transformer/ErasurePhase.java +++ b/sources/scalac/transformer/ErasurePhase.java @@ -75,12 +75,24 @@ public class ErasurePhase extends Phase { throw Debug.abort("illegal case", tp); } } + if (sym.isTerm() && sym.isParameter()) { + if (primitives.getPrimitive(sym.owner()) == Primitive.BOX) { + switch (tp) { + case TypeRef(Type prefix, Symbol clasz, Type[] args): + if (args.length > 0 && args[0].symbol().isAbstractType()) + return definitions.ANYREF_CLASS.nextType(); + break; + default: + throw Debug.abort("illegal case", tp); + } + } + } if (sym.isType()) return tp; // if (sym == definitions.NULL) return tp.resultType().erasure(); switch (primitives.getPrimitive(sym)) { case Primitive.IS : return Type.PolyType(tp.typeParams(), Type.MethodType(tp.valueParams(), tp.resultType().erasure())); case Primitive.AS : return tp; - case Primitive.BOX: return eraseParams(tp); + case Primitive.BOX: return eraseBoxMethodType(tp); case Primitive.AS__ARRAY: return Type.MethodType(Symbol.EMPTY_ARRAY, definitions.ANY_CLASS.nextType()); default : return tp.erasure(); @@ -99,16 +111,16 @@ public class ErasurePhase extends Phase { //######################################################################## // Private Methods - private Type eraseParams(Type tp) { - switch (tp) { + private Type eraseBoxMethodType(Type type) { + switch (type) { case PolyType(_, Type result): - return eraseParams(result); + return eraseBoxMethodType(result); case MethodType(Symbol[] params, Type result): - Symbol[] params1 = Type.erasureMap.map(params); - if (params1 == params) return tp; - else return Type.MethodType(params1, result); + return Type.MethodType(params, eraseBoxMethodType(result)); + case TypeRef(Type prefix, Symbol clasz, Type[] args): + return Type.TypeRef(prefix, clasz, Type.EMPTY_ARRAY); default: - return tp; + throw Debug.abort("illegal case", type); } } |