Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-02-15 10:05:16 +0000
committerManoj Palat2019-02-15 10:05:16 +0000
commit75678f56c16789d0e34a7ff19deb7688059a0f16 (patch)
treee16c6c0e7078d03d5d258cf946351ae81569ed0c /org.eclipse.jdt.core.tests.compiler/src
parent0dafaea9437765af6a924b8fc8f523beb778e26f (diff)
downloadeclipse.jdt.core-75678f56c16789d0e34a7ff19deb7688059a0f16.tar.gz
eclipse.jdt.core-75678f56c16789d0e34a7ff19deb7688059a0f16.tar.xz
eclipse.jdt.core-75678f56c16789d0e34a7ff19deb7688059a0f16.zip
Bug 544428 - [12][compiler] SwitchExpression.check_nonconstant_int
throws NPE
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler/src')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionTest.java34
1 files changed, 34 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 975170e227..2157b3906e 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
@@ -1885,4 +1885,38 @@ public class SwitchExpressionTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
+ public void testBug544428_01() {
+ Map<String, String> options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
+ options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int foo(int i) {\n" +
+ " var v = switch(i) {\n" +
+ " case 0 -> x;\n" +
+ " default -> 1;\n" +
+ " };\n" +
+ " return v;\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " System.out.println(new X().foo(0));\n" +
+ " }\n" +
+ "}",
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " case 0 -> x;\n" +
+ " ^\n" +
+ "x cannot be resolved to a variable\n" +
+ "----------\n";
+ this.runNegativeTest(
+ testFiles,
+ expectedProblemLog,
+ null,
+ true,
+ new String[] { "--enable-preview"},
+ options);
+ }
} \ No newline at end of file

Back to the top