Fix for KT-4357: Compiler error with infix call to Array.get
#KT-4357 Fixed
This commit is contained in:
@@ -39,10 +39,18 @@ public class ArrayGet extends IntrinsicMethod {
|
||||
List<JetExpression> arguments,
|
||||
StackValue receiver
|
||||
) {
|
||||
int argumentIndex;
|
||||
if (receiver == null || receiver == StackValue.none()) {
|
||||
receiver = codegen.gen(arguments.get(0));
|
||||
argumentIndex = 1;
|
||||
} else {
|
||||
argumentIndex = 0;
|
||||
}
|
||||
receiver.put(receiver.type, v);
|
||||
|
||||
Type type = correctElementType(receiver.type);
|
||||
|
||||
codegen.gen(arguments.get(0), Type.INT_TYPE);
|
||||
codegen.gen(arguments.get(argumentIndex), Type.INT_TYPE);
|
||||
|
||||
v.aload(type);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun box(): String {
|
||||
val array = intArray(11, 12, 13)
|
||||
val p = array get 0
|
||||
if (p != 11) return "fail 1: $p"
|
||||
|
||||
val stringArray = array("OK", "FAIL")
|
||||
return stringArray get 0
|
||||
}
|
||||
+6
@@ -129,6 +129,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4357.kt")
|
||||
public void testKt4357() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/arrays/kt4357.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/boxingOptimization")
|
||||
|
||||
Reference in New Issue
Block a user