Fix for KT-7288: VerifyError on accessing array element in 'is' block
#KT-7288 Fixed
This commit is contained in:
@@ -3581,7 +3581,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
else {
|
||||
elementType = correctElementType(arrayType);
|
||||
}
|
||||
StackValue arrayValue = gen(array);
|
||||
StackValue arrayValue = genLazy(array, arrayType);
|
||||
StackValue index = genLazy(indices.get(0), Type.INT_TYPE);
|
||||
|
||||
return StackValue.arrayElement(elementType, arrayValue, index);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//test [], get and iterator calls
|
||||
fun test(createIntNotLong: Boolean): String {
|
||||
val a = if (createIntNotLong) IntArray(5) else LongArray(5)
|
||||
if (a is IntArray) {
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a[i] != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "O"
|
||||
} else if (a is LongArray) {
|
||||
val x = a.iterator()
|
||||
var i = 0
|
||||
while (x.hasNext()) {
|
||||
if (a.get(i) != x.next()) return "Fail $i"
|
||||
i++
|
||||
}
|
||||
return "K"
|
||||
}
|
||||
return "fail"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test(true) + test(false)
|
||||
}
|
||||
+6
@@ -98,6 +98,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/arrays"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayInstanceOf.kt")
|
||||
public void testArrayInstanceOf() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/arrays/arrayInstanceOf.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayPlusAssign.kt")
|
||||
public void testArrayPlusAssign() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/arrays/arrayPlusAssign.kt");
|
||||
|
||||
Reference in New Issue
Block a user