Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-03-14 20:07:05 -0400
committerManoj Palat2019-03-14 20:07:05 -0400
commite2d24f0b92eac7f0e09c2a997511f00da5b8ed5e (patch)
tree5a58bd0973809821aa5a646086d777bab5bcf8d1
parent3d16613b8a0e378e939a2183c4584c10eb598c9a (diff)
downloadeclipse.jdt.core-e2d24f0b92eac7f0e09c2a997511f00da5b8ed5e.tar.gz
eclipse.jdt.core-e2d24f0b92eac7f0e09c2a997511f00da5b8ed5e.tar.xz
eclipse.jdt.core-e2d24f0b92eac7f0e09c2a997511f00da5b8ed5e.zip
bug 513766 comment 12 as additional test to bug 531714
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
index 6f4e3fbbdc..76b00319c9 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java
@@ -2206,4 +2206,32 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
+ // see comment 12 in the bug
+ public void testBug513766_01() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public void foo(int i) {\n"+
+ " if (switch(i) { default -> magic(); })\n"+
+ " System.out.println(\"true\");\n"+
+ " if (magic())\n"+
+ " System.out.println(\"true, too\");\n"+
+ " }\n"+
+ " <T> T magic() { return null; }\n"+
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " if (switch(i) { default -> magic(); })\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Object to boolean\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " if (magic())\n" +
+ " ^^^^^^^\n" +
+ "Type mismatch: cannot convert from Object to boolean\n" +
+ "----------\n");
+ }
} \ No newline at end of file

Back to the top