diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-08-26 13:28:37 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-08-26 13:28:37 +0000 |
commit | b3e8963c30de38a6d813640d58cbb1a0a00eba36 (patch) | |
tree | 95d646feeff954fb5c78077a82ed1fcf09282d24 /src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala | |
parent | cbb97ea1136982742344a0493cadb6080a19a082 (diff) | |
download | scala-b3e8963c30de38a6d813640d58cbb1a0a00eba36.tar.gz scala-b3e8963c30de38a6d813640d58cbb1a0a00eba36.tar.bz2 scala-b3e8963c30de38a6d813640d58cbb1a0a00eba36.zip |
Closes #3497.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index 0af482912d..b1be70a54c 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -580,17 +580,23 @@ abstract class ScalaPrimitives { import definitions._ val code = getPrimitive(fun) - var elem: Type = null - tpe match { - case TypeRef(_, sym, _elem :: Nil) - if (sym == ArrayClass) => elem = _elem - case _ => () + def elementType = atPhase(currentRun.typerPhase) { + val arrayParent = tpe :: tpe.parents find { + case TypeRef(_, sym, _elem :: Nil) + if (sym == ArrayClass) => true + case _ => false + } + if (arrayParent.isEmpty) { + println(fun.fullName + " : " + tpe :: tpe.baseTypeSeq.toList) + } + val TypeRef(_, _, elem :: Nil) = arrayParent.get + elem } code match { case APPLY => - toTypeKind(elem) match { + toTypeKind(elementType) match { case BOOL => ZARRAY_GET case BYTE => BARRAY_GET case SHORT => SARRAY_GET @@ -601,11 +607,11 @@ abstract class ScalaPrimitives { case DOUBLE => DARRAY_GET case REFERENCE(_) | ARRAY(_) => OARRAY_GET case _ => - abort("Unexpected array element type: " + elem) + abort("Unexpected array element type: " + elementType) } case UPDATE => - toTypeKind(elem) match { + toTypeKind(elementType) match { case BOOL => ZARRAY_SET case BYTE => BARRAY_SET case SHORT => SARRAY_SET @@ -616,12 +622,11 @@ abstract class ScalaPrimitives { case DOUBLE => DARRAY_SET case REFERENCE(_) | ARRAY(_) => OARRAY_SET case _ => - abort("Unexpected array element type: " + elem) + abort("Unexpected array element type: " + elementType) } case LENGTH => - assert(elem != null) - toTypeKind(elem) match { + toTypeKind(elementType) match { case BOOL => ZARRAY_LENGTH case BYTE => BARRAY_LENGTH case SHORT => SARRAY_LENGTH @@ -632,7 +637,7 @@ abstract class ScalaPrimitives { case DOUBLE => DARRAY_LENGTH case REFERENCE(_) | ARRAY(_) => OARRAY_LENGTH case _ => - abort("Unexpected array element type: " + elem) + abort("Unexpected array element type: " + elementType) } case _ => |