From e2d24f0b92eac7f0e09c2a997511f00da5b8ed5e Mon Sep 17 00:00:00 2001 From: Manoj Palat Date: Fri, 15 Mar 2019 05:37:05 +0530 Subject: bug 513766 comment 12 as additional test to bug 531714 --- .../compiler/regression/SwitchExpressionTest.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 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 -- cgit v1.2.3