diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-06-04 08:37:28 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-06-04 08:37:28 +0200 |
commit | 56f9140d4e3c8f697251897f30e2af677ddebf69 (patch) | |
tree | 9d30b2639e2b5597a46cf77f9aff372ba9dc6eed /src | |
parent | b24e7573a17332606d9f9da49a397e02abec1b63 (diff) | |
download | scala-56f9140d4e3c8f697251897f30e2af677ddebf69.tar.gz scala-56f9140d4e3c8f697251897f30e2af677ddebf69.tar.bz2 scala-56f9140d4e3c8f697251897f30e2af677ddebf69.zip |
Fix emitting Array(1).clone() in GenBCode
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala index 1285ca6862..bffa4bc51d 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala @@ -686,7 +686,12 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { case _ => } if ((targetTypeKind != null) && (sym == definitions.Array_clone) && invokeStyle.isDynamic) { - val target: String = targetTypeKind.asClassBType.internalName + // An invokevirtual points to a CONSTANT_Methodref_info which in turn points to a + // CONSTANT_Class_info of the receiver type. + // The JVMS is not explicit about this, but that receiver type may be an array type + // descriptor (instead of a class internal name): + // invokevirtual #2; //Method "[I".clone:()Ljava/lang/Object + val target: String = targetTypeKind.asRefBType.classOrArrayType bc.invokevirtual(target, "clone", "()Ljava/lang/Object;") } else { diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala index 9aedc7f8b4..5b0fa6f7a8 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala @@ -217,7 +217,8 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) { sealed trait RefBType extends BType { /** * The class or array type of this reference type. Used for ANEWARRAY, MULTIANEWARRAY, - * INSTANCEOF and CHECKCAST instructions. + * INSTANCEOF and CHECKCAST instructions. Also used for emitting invokevirtual calls to + * (a: Array[T]).clone() for any T, see genApply. * * In contrast to the descriptor, this string does not contain the surrounding 'L' and ';' for * class types, for example "java/lang/String". |