From e0cf73d9890bea299e5729ba229d7a9900d84e68 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 3 Dec 2013 18:39:12 +0400 Subject: [PATCH] Do not forget to process rhs on unsupported lhs --- .../jet/lang/cfg/JetControlFlowProcessor.java | 4 ++-- .../testData/cfg/assignmentToThis.instructions | 18 ++++++++++++++++++ compiler/testData/cfg/assignmentToThis.kt | 3 +++ .../jet/cfg/ControlFlowTestGenerated.java | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/cfg/assignmentToThis.instructions create mode 100644 compiler/testData/cfg/assignmentToThis.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index 6dc08ec889e..e2013ea6a00 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -358,11 +358,11 @@ public class JetControlFlowProcessor { return; } + generateInstructions(rhs, false); if (left instanceof JetSimpleNameExpression || left instanceof JetProperty) { - generateInstructions(rhs, false); + // Do nothing, just record write below } else if (left instanceof JetQualifiedExpression) { - generateInstructions(rhs, false); generateInstructions(((JetQualifiedExpression) left).getReceiverExpression(), false); } else { diff --git a/compiler/testData/cfg/assignmentToThis.instructions b/compiler/testData/cfg/assignmentToThis.instructions new file mode 100644 index 00000000000..bb018a1aeda --- /dev/null +++ b/compiler/testData/cfg/assignmentToThis.instructions @@ -0,0 +1,18 @@ +== bar == +fun Int.bar(c: C) { + this = c +} +--------------------- +L0: + NEXT:[v(c: C)] PREV:[] + v(c: C) NEXT:[w(c)] PREV:[] + w(c) NEXT:[r(c)] PREV:[v(c: C)] + r(c) NEXT:[unsupported(BINARY_EXPRESSION : this = c)] PREV:[w(c)] + unsupported(BINARY_EXPRESSION : this = c) NEXT:[] PREV:[r(c)] +L1: + NEXT:[] PREV:[unsupported(BINARY_EXPRESSION : this = c)] +error: + NEXT:[] PREV:[] +sink: + NEXT:[] PREV:[, ] +===================== diff --git a/compiler/testData/cfg/assignmentToThis.kt b/compiler/testData/cfg/assignmentToThis.kt new file mode 100644 index 00000000000..49942529bca --- /dev/null +++ b/compiler/testData/cfg/assignmentToThis.kt @@ -0,0 +1,3 @@ +fun Int.bar(c: C) { + this = c +} diff --git a/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java b/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java index 5c2a32dab38..0e367eda23b 100644 --- a/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java @@ -61,6 +61,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { doTest("compiler/testData/cfg/arraySetPlusAssign.kt"); } + @TestMetadata("assignmentToThis.kt") + public void testAssignmentToThis() throws Exception { + doTest("compiler/testData/cfg/assignmentToThis.kt"); + } + @TestMetadata("Assignments.kt") public void testAssignments() throws Exception { doTest("compiler/testData/cfg/Assignments.kt");