Fixed: control flow graph building for array of functions.

'get' call for array should be get from INDEXED_LVALUE_GET
This commit is contained in:
Svetlana Isakova
2013-12-06 15:57:56 +04:00
parent 3966f36b0c
commit 4c4e192914
4 changed files with 35 additions and 2 deletions
@@ -875,8 +875,9 @@ public class JetControlFlowProcessor {
@Override
public void visitArrayAccessExpression(@NotNull JetArrayAccessExpression expression) {
mark(expression);
if (!generateCall(expression)) {
generateArrayAccess(expression, getResolvedCall(expression));
ResolvedCall<FunctionDescriptor> getMethodResolvedCall = trace.get(BindingContext.INDEXED_LVALUE_GET, expression);
if (!checkAndGenerateCall(expression, getMethodResolvedCall)) {
generateArrayAccess(expression, getMethodResolvedCall);
}
}
@@ -0,0 +1,24 @@
== test ==
fun test(array: Array<(Int)->Unit>) {
array[11](3)
}
---------------------
L0:
<START>
v(array: Array<(Int)->Unit>)
w(array)
mark({ array[11](3) })
mark(array[11](3))
mark(array[11])
r(array)
r(11)
call(array[11], get)
r(3)
call(array[11], <for expression array[11]>)
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,3 @@
fun test(array: Array<(Int)->Unit>) {
array[11](3)
}
@@ -52,6 +52,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
doTest("compiler/testData/cfg/arrayAccessExpression.kt");
}
@TestMetadata("ArrayOfFunctions.kt")
public void testArrayOfFunctions() throws Exception {
doTest("compiler/testData/cfg/ArrayOfFunctions.kt");
}
@TestMetadata("arraySet.kt")
public void testArraySet() throws Exception {
doTest("compiler/testData/cfg/arraySet.kt");