Support empty if-statements

Type-check "if (...) ;" to Unit, report "implicit cast to Unit", propagate data
flow info out of its condition

 #KT-2478 Fixed
This commit is contained in:
Alexander Udalov
2013-12-02 20:30:55 +04:00
parent f045a06dee
commit 4cd4026174
7 changed files with 72 additions and 8 deletions
@@ -1565,6 +1565,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/controlStructures"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("emptyIf.kt")
public void testEmptyIf() throws Exception {
doTest("compiler/testData/diagnostics/tests/controlStructures/emptyIf.kt");
}
@TestMetadata("forLoopWithNullableRange.kt")
public void testForLoopWithNullableRange() throws Exception {
doTest("compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt");
@@ -1757,6 +1762,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt");
}
@TestMetadata("EmptyIf.kt")
public void testEmptyIf() throws Exception {
doTest("compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt");
}
@TestMetadata("IsExpression.kt")
public void testIsExpression() throws Exception {
doTest("compiler/testData/diagnostics/tests/dataFlow/IsExpression.kt");
@@ -3917,7 +3927,7 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
public void testContains() throws Exception {
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/contains.kt");
}
@TestMetadata("mathOperations.kt")
public void testMathOperations() throws Exception {
doTest("compiler/testData/diagnostics/tests/inline/binaryExpressions/mathOperations.kt");
@@ -1427,6 +1427,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/controlStructures/doWhileFib.kt");
}
@TestMetadata("emptyIf.kt")
public void testEmptyIf() throws Exception {
doTest("compiler/testData/codegen/box/controlStructures/emptyIf.kt");
}
@TestMetadata("finallyOnEmptyReturn.kt")
public void testFinallyOnEmptyReturn() throws Exception {
doTest("compiler/testData/codegen/box/controlStructures/finallyOnEmptyReturn.kt");