Fixed VerifyError when copyToArray() is immediately returned from method.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
+6
-1
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user