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 e2013ea6a00..6c5ba73d2f0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -288,7 +288,6 @@ public class JetControlFlowProcessor { } else if (operationType == JetTokens.ELVIS) { generateInstructions(expression.getLeft(), false); - generateInstructions(operationReference, false); Label afterElvis = builder.createUnboundLabel(); builder.jumpOnTrue(afterElvis); if (right != null) { diff --git a/compiler/testData/cfg/DeadCode.instructions b/compiler/testData/cfg/deadCode/DeadCode.instructions similarity index 100% rename from compiler/testData/cfg/DeadCode.instructions rename to compiler/testData/cfg/deadCode/DeadCode.instructions diff --git a/compiler/testData/cfg/DeadCode.kt b/compiler/testData/cfg/deadCode/DeadCode.kt similarity index 100% rename from compiler/testData/cfg/DeadCode.kt rename to compiler/testData/cfg/deadCode/DeadCode.kt diff --git a/compiler/testData/cfg/deadCode/returnInElvis.instructions b/compiler/testData/cfg/deadCode/returnInElvis.instructions new file mode 100644 index 00000000000..6b578975175 --- /dev/null +++ b/compiler/testData/cfg/deadCode/returnInElvis.instructions @@ -0,0 +1,18 @@ +== foo == +fun foo() { + return ?: null +} +--------------------- +L0: + NEXT:[ret L1] PREV:[] + ret L1 NEXT:[] PREV:[] +- jt(L2) NEXT:[r(null), ] PREV:[] +- r(null) NEXT:[] PREV:[] +L1: +L2: + NEXT:[] PREV:[ret L1] +error: + NEXT:[] PREV:[] +sink: + NEXT:[] PREV:[, ] +===================== diff --git a/compiler/testData/cfg/deadCode/returnInElvis.kt b/compiler/testData/cfg/deadCode/returnInElvis.kt new file mode 100644 index 00000000000..4adac5f9073 --- /dev/null +++ b/compiler/testData/cfg/deadCode/returnInElvis.kt @@ -0,0 +1,3 @@ +fun foo() { + return ?: null +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java b/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java index 0e367eda23b..b06b5d9f3d7 100644 --- a/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java @@ -31,6 +31,7 @@ import org.jetbrains.jet.cfg.AbstractControlFlowTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("compiler/testData/cfg") +@InnerTestClasses({ControlFlowTestGenerated.DeadCode.class}) public class ControlFlowTestGenerated extends AbstractControlFlowTest { public void testAllFilesPresentInCfg() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/cfg"), Pattern.compile("^(.+)\\.kt$"), true); @@ -81,11 +82,6 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { doTest("compiler/testData/cfg/Basic.kt"); } - @TestMetadata("DeadCode.kt") - public void testDeadCode() throws Exception { - doTest("compiler/testData/cfg/DeadCode.kt"); - } - @TestMetadata("DelegatedProperty.kt") public void testDelegatedProperty() throws Exception { doTest("compiler/testData/cfg/DelegatedProperty.kt"); @@ -216,4 +212,28 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { doTest("compiler/testData/cfg/unusedFunctionLiteral.kt"); } + @TestMetadata("compiler/testData/cfg/deadCode") + public static class DeadCode extends AbstractControlFlowTest { + public void testAllFilesPresentInDeadCode() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/cfg/deadCode"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("DeadCode.kt") + public void testDeadCode() throws Exception { + doTest("compiler/testData/cfg/deadCode/DeadCode.kt"); + } + + @TestMetadata("returnInElvis.kt") + public void testReturnInElvis() throws Exception { + doTest("compiler/testData/cfg/deadCode/returnInElvis.kt"); + } + + } + + public static Test suite() { + TestSuite suite = new TestSuite("ControlFlowTestGenerated"); + suite.addTestSuite(ControlFlowTestGenerated.class); + suite.addTestSuite(DeadCode.class); + return suite; + } }