KT-12983 java.lang.VerifyError: Bad type on operand stack in arraylength
Use proper receiver value type.
This commit is contained in:
@@ -1197,7 +1197,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
loopParameter().store(StackValue.constant(0, asmElementType), v);
|
||||
|
||||
StackValue receiver = generateReceiverValue(receiverValue, false);
|
||||
receiver.put(receiver.type, v);
|
||||
Type receiverType = asmType(receiverValue.getType());
|
||||
receiver.put(receiverType, v); // NB receiverType is a collection or an array
|
||||
getReceiverSizeAsInt();
|
||||
v.iconst(1);
|
||||
v.sub(Type.INT_TYPE);
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class BaseGeneric<T>(val t: T) {
|
||||
abstract fun iterate()
|
||||
}
|
||||
|
||||
class Derived<T>(array: Array<T>) : BaseGeneric<Array<T>>(array) {
|
||||
var test = 0
|
||||
|
||||
override fun iterate() {
|
||||
test = 0
|
||||
for (i in t.indices) {
|
||||
test = test * 10 + (i + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val t = Derived(arrayOf("", "", "", ""))
|
||||
t.iterate()
|
||||
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class BaseGeneric<T>(val t: T) {
|
||||
abstract fun iterate()
|
||||
}
|
||||
|
||||
class Derived<T>(t: List<T>) : BaseGeneric<List<T>>(t) {
|
||||
var test = 0
|
||||
|
||||
override fun iterate() {
|
||||
test = 0
|
||||
for (i in t.indices) {
|
||||
test = test * 10 + (i + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val t = Derived(listOf("", "", "", ""))
|
||||
t.iterate()
|
||||
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class BaseGeneric<T>(val t: T) {
|
||||
abstract fun iterate()
|
||||
}
|
||||
|
||||
class Derived(array: DoubleArray) : BaseGeneric<DoubleArray>(array) {
|
||||
var test = 0
|
||||
|
||||
override fun iterate() {
|
||||
test = 0
|
||||
for (i in t.indices) {
|
||||
test = test * 10 + (i + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val t = Derived(doubleArrayOf(0.0, 0.0, 0.0, 0.0))
|
||||
t.iterate()
|
||||
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class BaseGeneric<T>(val t: T) {
|
||||
abstract fun iterate()
|
||||
}
|
||||
|
||||
class Derived(t: List<Int>) : BaseGeneric<List<Int>>(t) {
|
||||
var test = 0
|
||||
|
||||
override fun iterate() {
|
||||
test = 0
|
||||
for (i in t.indices) {
|
||||
test = test * 10 + (i + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val t = Derived(listOf(1, 2, 3, 4))
|
||||
t.iterate()
|
||||
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
|
||||
}
|
||||
@@ -10925,6 +10925,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInIndices/forNullableIntInCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt12983_forInGenericArrayIndices.kt")
|
||||
public void testKt12983_forInGenericArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInIndices/kt12983_forInGenericArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt12983_forInGenericCollectionIndices.kt")
|
||||
public void testKt12983_forInGenericCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInIndices/kt12983_forInGenericCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt12983_forInSpecificArrayIndices.kt")
|
||||
public void testKt12983_forInSpecificArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInIndices/kt12983_forInSpecificArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt12983_forInSpecificCollectionIndices.kt")
|
||||
public void testKt12983_forInSpecificCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInIndices/kt12983_forInSpecificCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ranges/literal")
|
||||
|
||||
Reference in New Issue
Block a user