summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Namers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-04-11 10:49:20 +0000
committerMartin Odersky <odersky@gmail.com>2011-04-11 10:49:20 +0000
commita8f2ea50ac5df04ff11df33f7808e392c56aca0e (patch)
treecc176b37a64ae91b1652e884fc706fc4a0037b45 /src/compiler/scala/tools/nsc/typechecker/Namers.scala
parent66956b745fb2643f6374122b634ade5afc31fab9 (diff)
downloadscala-a8f2ea50ac5df04ff11df33f7808e392c56aca0e.tar.gz
scala-a8f2ea50ac5df04ff11df33f7808e392c56aca0e.tar.bz2
scala-a8f2ea50ac5df04ff11df33f7808e392c56aca0e.zip
Closes #4390, unfortunately by taking the stric...
Closes #4390, unfortunately by taking the stricter standpoint. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Namers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index f966e1476c..3b3eb74745 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -557,7 +557,7 @@ trait Namers { self: Analyzer =>
}
case _ =>
}
- sym.setInfo(tp)
+ sym.setInfo(if (sym.isJavaDefined) RestrictJavaArraysMap(tp) else tp)
if ((sym.isAliasType || sym.isAbstractType) && !sym.isParameter &&
!typer.checkNonCyclic(tree.pos, tp))
sym.setInfo(ErrorType) // this early test is there to avoid infinite baseTypes when
@@ -1279,6 +1279,20 @@ trait Namers { self: Analyzer =>
}
}
+ /** Convert Java generic array type T[] to (T with Object)[]
+ * (this is necessary because such arrays have a representation which is incompatible
+ * with arrays of primitive types.)
+ */
+ private object RestrictJavaArraysMap extends TypeMap {
+ def apply(tp: Type): Type = tp match {
+ case TypeRef(pre, ArrayClass, List(elemtp))
+ if elemtp.typeSymbol.isAbstractType && !(elemtp <:< definitions.ObjectClass.tpe) =>
+ TypeRef(pre, ArrayClass, List(intersectionType(List(elemtp, definitions.ObjectClass.tpe))))
+ case _ =>
+ mapOver(tp)
+ }
+ }
+
/** Check that symbol's definition is well-formed. This means:
* - no conflicting modifiers
* - `abstract' modifier only for classes