Fixed VerifyError when copyToArray() is immediately returned from method.

This commit is contained in:
Evgeny Gerashchenko
2013-10-01 18:58:08 +04:00
parent 94cb523eb7
commit dc42be8543
3 changed files with 18 additions and 1 deletions
@@ -31,6 +31,8 @@ public class CopyToArray implements IntrinsicMethod {
v.newarray(expectedType.getElementType());
v.invokeinterface("java/util/Collection", "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;");
StackValue.coerce(Type.getType("[Ljava/lang/Object;"), expectedType, v);
return StackValue.onStack(expectedType);
}
}
@@ -0,0 +1,10 @@
import java.util.Arrays
fun getCopyToArray(): Array<Int> = Arrays.asList(2, 3, 9).copyToArray()
fun box(): String {
val str = Arrays.toString(getCopyToArray())
if (str != "[2, 3, 9]") return str
return "OK"
}
@@ -955,7 +955,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
public void testKt3177_copyToArray() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/toArray/kt3177-copyToArray.kt");
}
@TestMetadata("returnCopyToArray.kt")
public void testReturnCopyToArray() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/toArray/returnCopyToArray.kt");
}
}
public static Test suite() {