diff options
author | Martin Odersky <odersky@gmail.com> | 2011-04-11 10:49:20 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-04-11 10:49:20 +0000 |
commit | a8f2ea50ac5df04ff11df33f7808e392c56aca0e (patch) | |
tree | cc176b37a64ae91b1652e884fc706fc4a0037b45 | |
parent | 66956b745fb2643f6374122b634ade5afc31fab9 (diff) | |
download | scala-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.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 16 |
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 |