Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2021-08-18 23:55:00 +0000
committerManoj Palat2021-08-19 01:45:16 +0000
commitb6897bc85ee17c73d3afb74a6f80c0d21fd34199 (patch)
treec6d3a7f6da7ae6635b1cdcd5d3e4e0994166eb48 /org.eclipse.jdt.core.tests.compiler
parent8df730f482c7b9813cb873cc14623e7489f30862 (diff)
downloadeclipse.jdt.core-b6897bc85ee17c73d3afb74a6f80c0d21fd34199.tar.gz
eclipse.jdt.core-b6897bc85ee17c73d3afb74a6f80c0d21fd34199.tar.xz
eclipse.jdt.core-b6897bc85ee17c73d3afb74a6f80c0d21fd34199.zip
Bug 575058 - [17][test] flag error If the Pattern is total for the type
of the expression RelationalExpression Change-Id: If951e8368091c4438b5acbb265d866174d9121f8 Signed-off-by: Manoj Palat <manpalat@in.ibm.com> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/184220 Tested-by: JDT Bot <jdt-bot@eclipse.org>
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InstanceofPrimaryPatternTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InstanceofPrimaryPatternTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InstanceofPrimaryPatternTest.java
index a7e78ff571..4b17c7d27a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InstanceofPrimaryPatternTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InstanceofPrimaryPatternTest.java
@@ -250,4 +250,26 @@ public class InstanceofPrimaryPatternTest extends AbstractRegressionTest {
"The method Zork() is undefined for the type X\n" +
"----------\n");
}
+ public void test009() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void foo(String s) {\n" +
+ " if (s instanceof Object o) {\n" +
+ " System.out.println(s);\n" +
+ " }\n " +
+ " }\n" +
+ " public static void main(String[] obj) {\n" +
+ " foo(\"Hello World!\");\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " if (s instanceof Object o) {\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Expression type cannot be a subtype of the Pattern type\n" +
+ "----------\n");
+ }
} \ No newline at end of file

Back to the top