summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-12-20 16:35:10 +0000
committerMartin Odersky <odersky@gmail.com>2007-12-20 16:35:10 +0000
commita703d69eab35c7008ccf18836101fbc5c592b376 (patch)
treebcad85e9ac4b0a738b84f8b3b8c424cb027cf5e6 /src
parent8ad43107f52b278930a663874943de9eda0c8df0 (diff)
downloadscala-a703d69eab35c7008ccf18836101fbc5c592b376.tar.gz
scala-a703d69eab35c7008ccf18836101fbc5c592b376.tar.bz2
scala-a703d69eab35c7008ccf18836101fbc5c592b376.zip
fixed build problem on ibm's VM
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala32
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala5
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
3 files changed, 33 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index e16e1be2d6..a773fcd79e 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -2464,6 +2464,32 @@ A type's typeSymbol should never be inspected directly.
owner.newAbstractType(owner.pos, newTypeName(freshTypeName()+suffix)).setFlag(EXISTENTIAL)
).setInfo(bounds)
+ def typeParamsToExistentials(clazz: Symbol, tparams: List[Symbol]): List[Symbol] = {
+ val eparams = for (tparam <- tparams) yield {
+ makeExistential("", clazz, tparam.info.bounds)
+ }
+ for (val tparam <- eparams) tparam setInfo tparam.info.substSym(tparams, eparams)
+ eparams
+ }
+
+ /** The raw to existential map converts a ``raw type'' to an existential type.
+ * It is necessary because we might have read a raw type of a
+ * parameterized Java class from a class file. At the time we read the type
+ * the corresponding class file might still not be read, so we do not
+ * know what the type parameters of the type are. Therefore
+ * the conversion of raw types to existential types might not have taken place
+ * in ClassFileparser.sigToType (where it is usually done)
+ */
+ object rawToExistential extends TypeMap {
+ def apply(tp: Type): Type = tp match {
+ case TypeRef(pre, sym, List()) if (sym.hasFlag(JAVA) && !sym.typeParams.isEmpty) =>
+ val eparams = typeParamsToExistentials(sym, sym.typeParams)
+ existentialAbstraction(eparams, TypeRef(pre, sym, eparams map (_.tpe)))
+ case _ =>
+ mapOver(tp)
+ }
+ }
+
/** A map to compute the asSeenFrom method */
class AsSeenFromMap(pre: Type, clazz: Symbol) extends TypeMap {
override val dropNonConstraintAnnotations = true
@@ -2579,13 +2605,15 @@ A type's typeSymbol should never be inspected directly.
pre.baseType(symclazz) match {
case TypeRef(_, basesym, baseargs) =>
//Console.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs+", pre = "+pre+", symclazz = "+symclazz);//DEBUG
- if (basesym.typeParams.length != baseargs.length)
+ if (basesym.typeParams.length == baseargs.length) {
+ instParam(basesym.typeParams, baseargs)
+ } else {
throw new TypeError(
"something is wrong (wrong class file?): "+basesym+
" with type parameters "+
basesym.typeParams.map(_.name).mkString("[",",","]")+
" gets applied to arguments "+baseargs.mkString("[",",","]")+", phase = "+phase)
- instParam(basesym.typeParams, baseargs);
+ }
case ExistentialType(tparams, qtpe) =>
capturedParams = capturedParams union tparams
toInstance(qtpe, clazz)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 73b81107ee..987411c6d8 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -503,10 +503,7 @@ abstract class ClassfileParser {
else if (classSym.isMonomorphicType) classSym.tpe
else {
// raw type - existentially quantify all type parameters
- val eparams = for (tparam <- classSym.unsafeTypeParams) yield {
- val newSym = clazz.newAbstractType(NoPosition, fresh.newName)
- newSym.setInfo(tparam.info.bounds) setFlag EXISTENTIAL
- }
+ val eparams = typeParamsToExistentials(classSym, classSym.unsafeTypeParams)
val t = appliedType(classSym.typeConstructor, eparams.map(_.tpe))
val res = existentialAbstraction(eparams, t)
if (settings.debug.value && settings.verbose.value) println("raw type " + classSym + " -> " + res)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index f3d0208ab5..8571148479 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -328,6 +328,8 @@ trait Infer {
else " contains a "+ex.msg))
ErrorType
}
+ if (sym1.isTerm && (sym1 hasFlag JAVA))
+ owntype = rawToExistential(owntype)
if (pre.isInstanceOf[SuperType])
owntype = owntype.substSuper(pre, site.symbol.thisType)
tree setSymbol sym1 setType owntype