Properly process this in callee position
This commit is contained in:
@@ -190,7 +190,19 @@ public class JetControlFlowProcessor {
|
||||
@Override
|
||||
public void visitThisExpression(@NotNull JetThisExpression expression) {
|
||||
ResolvedCall<?> resolvedCall = getResolvedCall(expression);
|
||||
builder.readThis(expression, resolvedCall == null ? null : (ReceiverParameterDescriptor) resolvedCall.getResultingDescriptor());
|
||||
if (resolvedCall == null) {
|
||||
builder.readThis(expression, null);
|
||||
return;
|
||||
}
|
||||
|
||||
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||
if (resultingDescriptor instanceof ReceiverParameterDescriptor) {
|
||||
builder.readThis(expression, (ReceiverParameterDescriptor) resultingDescriptor);
|
||||
}
|
||||
else if (resultingDescriptor instanceof ExpressionAsFunctionDescriptor) {
|
||||
// TODO: no information about actual target
|
||||
builder.readThis(expression, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
== invoke ==
|
||||
fun invoke(f: () -> Unit) {
|
||||
(f)()
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
<START> NEXT:[v(f: () -> Unit)] PREV:[]
|
||||
v(f: () -> Unit) NEXT:[w(f)] PREV:[<START>]
|
||||
w(f) NEXT:[r(f)] PREV:[v(f: () -> Unit)]
|
||||
r(f) NEXT:[call((f), <for expression (f)>)] PREV:[w(f)]
|
||||
call((f), <for expression (f)>) NEXT:[<END>] PREV:[r(f)]
|
||||
L1:
|
||||
<END> NEXT:[<SINK>] PREV:[call((f), <for expression (f)>)]
|
||||
error:
|
||||
<ERROR> NEXT:[<SINK>] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,3 @@
|
||||
fun invoke(f: () -> Unit) {
|
||||
(f)()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
== foo ==
|
||||
fun Function0<Unit>.foo() {
|
||||
this()
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
<START> NEXT:[r(this)] PREV:[]
|
||||
r(this) NEXT:[call(this, <for expression this>)] PREV:[<START>]
|
||||
call(this, <for expression this>) NEXT:[<END>] PREV:[r(this)]
|
||||
L1:
|
||||
<END> NEXT:[<SINK>] PREV:[call(this, <for expression this>)]
|
||||
error:
|
||||
<ERROR> NEXT:[<SINK>] PREV:[]
|
||||
sink:
|
||||
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,3 @@
|
||||
fun Function0<Unit>.foo() {
|
||||
this()
|
||||
}
|
||||
@@ -86,6 +86,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
||||
doTest("compiler/testData/cfg/equals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expressionAsFunction.kt")
|
||||
public void testExpressionAsFunction() throws Exception {
|
||||
doTest("compiler/testData/cfg/expressionAsFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FailFunction.kt")
|
||||
public void testFailFunction() throws Exception {
|
||||
doTest("compiler/testData/cfg/FailFunction.kt");
|
||||
@@ -176,6 +181,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
||||
doTest("compiler/testData/cfg/ShortFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("thisExpression.kt")
|
||||
public void testThisExpression() throws Exception {
|
||||
doTest("compiler/testData/cfg/thisExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameter.kt")
|
||||
public void testTypeParameter() throws Exception {
|
||||
doTest("compiler/testData/cfg/typeParameter.kt");
|
||||
|
||||
Reference in New Issue
Block a user