KT-3820 VerifyError when invoking intrinsic for range obtained from collection

#KT-3820 fixed
This commit is contained in:
Evgeny Gerashchenko
2013-07-30 09:10:39 -07:00
parent aafa492c95
commit 7f62b9259c
6 changed files with 26 additions and 3 deletions
@@ -56,7 +56,7 @@ public class PropertyOfProgressionOrRange implements IntrinsicMethod {
JvmClassName wrapperClass = JvmPrimitiveType.getByAsmType(expectedType).getWrapper();
String getterName = PropertyCodegen.getterName(propertyName);
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
receiver.put(receiver.type, v);
v.invokevirtual(ownerInternalName, getterName, "()" + wrapperClass.getDescriptor());
StackValue.coerce(wrapperClass.getAsmType(), expectedType, v);
return StackValue.onStack(expectedType);
@@ -40,7 +40,7 @@ public class StringGetChar implements IntrinsicMethod {
@NotNull GenerationState state
) {
if (receiver != null) {
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
receiver.put(receiver.type, v);
}
if (arguments != null) {
codegen.gen(arguments.get(0)).put(Type.INT_TYPE, v);
@@ -39,7 +39,7 @@ public class StringLength implements IntrinsicMethod {
StackValue receiver,
@NotNull GenerationState state
) {
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
receiver.put(receiver.type, v);
v.invokeinterface("java/lang/CharSequence", "length", "()I");
return StackValue.onStack(Type.INT_TYPE);
}
@@ -0,0 +1,6 @@
fun box(): String {
val list = java.util.ArrayList<IntRange>()
list.add(1..3)
list[0].start
return "OK"
}
@@ -0,0 +1,7 @@
fun box(): String {
val list = java.util.ArrayList<String>()
list.add("0")
list[0][0]
list[0].length
return "OK"
}
@@ -2455,6 +2455,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/intrinsics/longRangeWithExplicitDot.kt");
}
@TestMetadata("rangeFromCollection.kt")
public void testRangeFromCollection() throws Exception {
doTest("compiler/testData/codegen/box/intrinsics/rangeFromCollection.kt");
}
@TestMetadata("stringFromCollection.kt")
public void testStringFromCollection() throws Exception {
doTest("compiler/testData/codegen/box/intrinsics/stringFromCollection.kt");
}
@TestMetadata("tostring.kt")
public void testTostring() throws Exception {
doTest("compiler/testData/codegen/box/intrinsics/tostring.kt");