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.newarray(expectedType.getElementType());
|
||||||
v.invokeinterface("java/util/Collection", "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;");
|
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);
|
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"
|
||||||
|
}
|
||||||
+5
@@ -956,6 +956,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/toArray/kt3177-copyToArray.kt");
|
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() {
|
public static Test suite() {
|
||||||
|
|||||||
Reference in New Issue
Block a user