Proper read instructions for function literals
This commit is contained in:
@@ -88,6 +88,7 @@ public interface JetControlFlowBuilder {
|
|||||||
void loadUnit(@NotNull JetExpression expression);
|
void loadUnit(@NotNull JetExpression expression);
|
||||||
void loadConstant(@NotNull JetExpression expression, @Nullable CompileTimeConstant<?> constant);
|
void loadConstant(@NotNull JetExpression expression, @Nullable CompileTimeConstant<?> constant);
|
||||||
void createAnonymousObject(@NotNull JetObjectLiteralExpression expression);
|
void createAnonymousObject(@NotNull JetObjectLiteralExpression expression);
|
||||||
|
void createFunctionLiteral(@NotNull JetFunctionLiteralExpression expression);
|
||||||
void loadStringTemplate(@NotNull JetStringTemplateExpression expression);
|
void loadStringTemplate(@NotNull JetStringTemplateExpression expression);
|
||||||
|
|
||||||
void readThis(@NotNull JetExpression expression, @Nullable ReceiverParameterDescriptor parameterDescriptor);
|
void readThis(@NotNull JetExpression expression, @Nullable ReceiverParameterDescriptor parameterDescriptor);
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
|||||||
getDelegateBuilder().createAnonymousObject(expression);
|
getDelegateBuilder().createAnonymousObject(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createFunctionLiteral(@NotNull JetFunctionLiteralExpression expression) {
|
||||||
|
getDelegateBuilder().createFunctionLiteral(expression);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadStringTemplate(@NotNull JetStringTemplateExpression expression) {
|
public void loadStringTemplate(@NotNull JetStringTemplateExpression expression) {
|
||||||
getDelegateBuilder().loadStringTemplate(expression);
|
getDelegateBuilder().loadStringTemplate(expression);
|
||||||
|
|||||||
@@ -700,6 +700,7 @@ public class JetControlFlowProcessor {
|
|||||||
public void visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression) {
|
public void visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression) {
|
||||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||||
processLocalDeclaration(functionLiteral);
|
processLocalDeclaration(functionLiteral);
|
||||||
|
builder.createFunctionLiteral(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
@@ -346,6 +346,11 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
read(expression);
|
read(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createFunctionLiteral(@NotNull JetFunctionLiteralExpression expression) {
|
||||||
|
read(expression);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadStringTemplate(@NotNull JetStringTemplateExpression expression) {
|
public void loadStringTemplate(@NotNull JetStringTemplateExpression expression) {
|
||||||
read(expression);
|
read(expression);
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
== foo ==
|
||||||
|
fun foo() {
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
---------------------
|
||||||
|
L0:
|
||||||
|
<START> NEXT:[jmp?(L2)] PREV:[]
|
||||||
|
jmp?(L2) NEXT:[r({}), d({})] PREV:[<START>]
|
||||||
|
d({}) NEXT:[<SINK>] PREV:[jmp?(L2)]
|
||||||
|
L2:
|
||||||
|
r({}) NEXT:[<END>] PREV:[jmp?(L2)]
|
||||||
|
L1:
|
||||||
|
<END> NEXT:[<SINK>] PREV:[r({})]
|
||||||
|
error:
|
||||||
|
<ERROR> NEXT:[<SINK>] PREV:[]
|
||||||
|
sink:
|
||||||
|
<SINK> NEXT:[] PREV:[<ERROR>, <END>, d({})]
|
||||||
|
L3:
|
||||||
|
<START> NEXT:[read (Unit)] PREV:[]
|
||||||
|
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||||
|
L4:
|
||||||
|
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||||
|
error:
|
||||||
|
<ERROR> NEXT:[<SINK>] PREV:[]
|
||||||
|
sink:
|
||||||
|
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
|
||||||
|
=====================
|
||||||
|
== anonymous_0 ==
|
||||||
|
{}
|
||||||
|
---------------------
|
||||||
|
L3:
|
||||||
|
<START> NEXT:[read (Unit)] PREV:[]
|
||||||
|
read (Unit) NEXT:[<END>] PREV:[<START>]
|
||||||
|
L4:
|
||||||
|
<END> NEXT:[<SINK>] PREV:[read (Unit)]
|
||||||
|
error:
|
||||||
|
<ERROR> NEXT:[<SINK>] PREV:[]
|
||||||
|
sink:
|
||||||
|
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
|
||||||
|
=====================
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo() {
|
||||||
|
{}
|
||||||
|
}
|
||||||
@@ -166,4 +166,9 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
|||||||
doTest("compiler/testData/cfg/unresolved.kt");
|
doTest("compiler/testData/cfg/unresolved.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unusedFunctionLiteral.kt")
|
||||||
|
public void testUnusedFunctionLiteral() throws Exception {
|
||||||
|
doTest("compiler/testData/cfg/unusedFunctionLiteral.kt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user