Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-06-10 05:55:04 -0400
committerManoj Palat2019-06-10 05:55:04 -0400
commit2540a46be8c4e39b5df4a06ab8e744bc6ab83a5a (patch)
tree34f726ccddb9213d9ad12567d6f7e9817fd10b74
parent9577951edaed0bb25f4dba4033f449a31e06c01c (diff)
downloadeclipse.jdt.core-2540a46be8c4e39b5df4a06ab8e744bc6ab83a5a.tar.gz
eclipse.jdt.core-2540a46be8c4e39b5df4a06ab8e744bc6ab83a5a.tar.xz
eclipse.jdt.core-2540a46be8c4e39b5df4a06ab8e744bc6ab83a5a.zip
Bug 544073 - further improvements - WIP
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java199
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java15
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java16
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java106
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java21
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java3
9 files changed, 252 insertions, 118 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
index a9b4acc4f7..efef781d1d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
@@ -24,14 +24,14 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug543240_1" };
+// TESTS_NAMES = new String[] { "testBug544073_035" };
}
public static Class<?> testClass() {
return SwitchExpressionsYieldTest.class;
}
public static Test suite() {
- return buildMinimalComplianceTestSuite(testClass(), F_12);
+ return buildMinimalComplianceTestSuite(testClass(), F_13);
}
public SwitchExpressionsYieldTest(String testName){
super(testName);
@@ -83,7 +83,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_001() {
+ public void testBug544073_001() {
runConformTest(
new String[] {
"X.java",
@@ -105,7 +105,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_002() {
+ public void testBug544073_002() {
runConformTest(
new String[] {
"X.java",
@@ -139,7 +139,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_003() {
+ public void testBug544073_003() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -167,7 +167,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"A switch expression should have a default case\n" +
"----------\n");
}
- public void _testBug544073_004() {
+ public void testBug544073_004() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -196,7 +196,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"Type mismatch: cannot convert from String to int\n" +
"----------\n");
}
- public void _testBug544073_005() {
+ public void testBug544073_005() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -231,7 +231,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
* must contain all the enum constants of that enum type
* Add a missing enum test case
*/
- public void __testBug544073_006() {
+ public void _testBug544073_006() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -268,7 +268,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
* should compile - test for adding additional nesting in variables
* dev note: ref consumeToken().case Switch
*/
- public void _testBug544073_007() {
+ public void testBug544073_007() {
runConformTest(
new String[] {
"X.java",
@@ -296,7 +296,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_008() {
+ public void testBug544073_008() {
Map<String, String> disablePreviewOptions = getCompilerOptions();
disablePreviewOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
String[] testFiles = new String[] {
@@ -350,7 +350,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
disablePreviewOptions);
}
- public void _testBug544073_009() {
+ public void testBug544073_009() {
runConformTest(
new String[] {
"X.java",
@@ -372,7 +372,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
false,
new String[] { "--enable-preview"});
}
- public void _testBug544073_010() {
+ public void testBug544073_010() {
Map<String, String> disablePreviewOptions = getCompilerOptions();
disablePreviewOptions.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED);
String[] testFiles = new String[] {
@@ -416,7 +416,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
disablePreviewOptions);
}
- public void _testBug544073_011() {
+ public void testBug544073_011() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.ERROR);
@@ -454,7 +454,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
options);
}
- public void _testBug544073_012() {
+ public void testBug544073_012() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
@@ -488,7 +488,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
getCompilerOptions());
}
- public void _testBug544073_013() {
+ public void testBug544073_013() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.WARNING);
@@ -516,11 +516,6 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
" default -> 3;\n" +
" ^^^^^^^\n" +
"The preview feature Case Labels with \'->\' is only available with source level 12 and above\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 4)\n" +
- " default -> 3;\n" +
- " ^\n" +
- "Invalid expression as statement\n" +
"----------\n";
this.runNegativeTest(
testFiles,
@@ -532,7 +527,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
options.put(CompilerOptions.OPTION_Source, release);
}
}
- public void _testBug544073_014() {
+ public void testBug544073_014() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -570,7 +565,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
getCompilerOptions());
}
- public void _testBug544073_015() {
+ public void testBug544073_015() {
// switch expression is not a Primary
Runner runner = new Runner();
runner.customOptions = getCompilerOptions();
@@ -597,7 +592,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"----------\n";
runner.runNegativeTest();
}
- public void _testBug544073_016() {
+ public void testBug544073_016() {
runConformTest(
new String[] {
"X.java",
@@ -628,7 +623,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* A simple multi constant case statement, compiled and run as expected
*/
- public void _testBug544073_017() {
+ public void testBug544073_017() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -662,7 +657,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* A simple multi constant case statement, compiler reports missing enum constants
*/
- public void _testBug544073_018() {
+ public void testBug544073_018() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -702,7 +697,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* A simple multi constant case statement with duplicate enums
*/
- public void _testBug544073_019() {
+ public void testBug544073_019() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -747,7 +742,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* A simple multi constant case statement with duplicate enums
*/
- public void _testBug544073_020() {
+ public void testBug544073_020() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -800,7 +795,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
*
*/
- public void _testBug544073_021() {
+ public void testBug544073_021() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -838,7 +833,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] {"--enable-preview"},
options);
}
- public void _testBug544073_022() {
+ public void testBug544073_022() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -876,7 +871,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Simple switch case with string literals
*/
- public void _testBug544073_023() {
+ public void testBug544073_023() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -915,7 +910,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
options,
new String[] {"--enable-preview"});
}
- public void _testBug544073_024() {
+ public void testBug544073_024() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -957,7 +952,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
* Switch with multi constant case statements with string literals
* two string literals with same hashcode
*/
- public void _testBug544073_025() {
+ public void testBug544073_025() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -998,7 +993,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch with multi constant case statements with integer constants
*/
- public void _testBug544073_026() {
+ public void testBug544073_026() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1041,7 +1036,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch multi-constant with mixed constant types, reported
*/
- public void _testBug544073_027() {
+ public void testBug544073_027() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1081,7 +1076,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch multi-constant without break statement, reported
*/
- public void _testBug544073_028() {
+ public void testBug544073_028() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1122,7 +1117,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch multi-constant without yield statement, reported
*/
- public void _testBug544073_029() {
+ public void testBug544073_029() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1160,7 +1155,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch multi-constant with duplicate int constants
*/
- public void _testBug544073_030() {
+ public void testBug544073_030() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1201,7 +1196,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch multi-constant with duplicate String literals
*/
- public void _testBug544073_031() {
+ public void testBug544073_031() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1242,7 +1237,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
/*
* Switch multi-constant with illegal qualified enum constant
*/
- public void _testBug544073_032() {
+ public void testBug544073_032() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1274,7 +1269,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
options);
}
- public void _testBug544073_033() {
+ public void testBug544073_033() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1303,7 +1298,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
options);
}
- public void _testBug544073_034() {
+ public void testBug544073_034() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1329,7 +1324,8 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void _testBug544073_035() {
+ public void testBug544073_035() {
+ // TODO: Fix me
this.runNegativeTest(
new String[] {
"X.java",
@@ -1369,7 +1365,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"Break of a switch expression should have a value\n" +
"----------\n");
}
- public void _testBug544073_036() {
+ public void testBug544073_036() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1400,7 +1396,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
true,
options);
}
- public void _testBug544073_037() {
+ public void testBug544073_037() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1424,7 +1420,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
String expectedOutput = "hello world";
runConformTest(testFiles, expectedOutput, options);
}
- public void _testBug544073_038() {
+ public void testBug544073_038() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1433,7 +1429,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"public class X {\n" +
" void test(int i) {\n" +
" need(switch (i) {\n" +
- " case 1: break \"\";\n" +
+ " case 1: yield \"\";\n" +
" default: yield i == 3 ? null : \"\";\n" +
" }); \n" +
" }\n" +
@@ -1448,7 +1444,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
String expectedOutput = "hello world";
runConformTest(testFiles, expectedOutput, options);
}
- public void _testBug544073_039() {
+ public void testBug544073_039() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1479,7 +1475,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
String expectedOutput = "NPE as expected";
runConformTest(testFiles, expectedOutput, options);
}
- public void _testBug544073_040() {
+ public void testBug544073_040() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1511,7 +1507,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
String expectedOutput = "NPE as expected";
runConformTest(testFiles, expectedOutput, options);
}
- public void _testBug544073_041() {
+ public void testBug544073_041() {
// require resolving/inferring of poly-switch-expression during ASTNode.resolvePolyExpressionArguments()
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
@@ -1536,7 +1532,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
String expectedOutput = "3";
runConformTest(testFiles, expectedOutput, options);
}
- public void _testBug544073_042() {
+ public void testBug544073_042() {
runConformTest(
new String[] {
"X.java",
@@ -1569,7 +1565,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_043() {
+ public void testBug544073_043() {
runConformTest(
new String[] {
"X.java",
@@ -1597,7 +1593,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_044() {
+ public void testBug544073_044() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
String[] testFiles = new String[] {
@@ -1630,7 +1626,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void _testBug544073_045() {
+ public void testBug544073_045() {
runConformTest(
new String[] {
"X.java",
@@ -1652,7 +1648,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_046() {
+ public void testBug544073_046() {
runConformTest(
new String[] {
"X.java",
@@ -1674,7 +1670,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_047() {
+ public void testBug544073_047() {
runConformTest(
new String[] {
"X.java",
@@ -1700,7 +1696,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_048() {
+ public void testBug544073_048() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -1738,7 +1734,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"A Switch expression should cover all possible values\n" +
"----------\n");
}
- public void _testBug544073_049() {
+ public void testBug544073_049() {
runConformTest(
new String[] {
"X.java",
@@ -1759,7 +1755,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_050() {
+ public void testBug544073_050() {
runConformTest(
new String[] {
"X.java",
@@ -1783,7 +1779,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_051() {
+ public void testBug544073_051() {
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
runConformTest(
@@ -1809,7 +1805,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
customOptions,
new String[] {"--enable-preview"});
}
- public void _testBug544073_052() {
+ public void testBug544073_052() {
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
runConformTest(
@@ -1835,7 +1831,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
customOptions,
new String[] {"--enable-preview"});
}
- public void _testBug544073_053() {
+ public void testBug544073_053() {
Map<String, String> customOptions = getCompilerOptions();
customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
runConformTest(
@@ -1858,7 +1854,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
customOptions,
new String[] {"--enable-preview"});
}
- public void _testBug544073_054() {
+ public void testBug544073_054() {
runConformTest(
new String[] {
"X.java",
@@ -1883,7 +1879,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_055() {
+ public void testBug544073_055() {
runConformTest(
new String[] {
"X.java",
@@ -1909,7 +1905,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_056() {
+ public void testBug544073_056() {
Map<String, String> options = getCompilerOptions();
options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.ENABLED);
options.put(CompilerOptions.OPTION_ReportPreviewFeatures, CompilerOptions.IGNORE);
@@ -1943,7 +1939,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void _testBug544073_057() {
+ public void testBug544073_057() {
runConformTest(
new String[] {
"X.java",
@@ -1968,7 +1964,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_058() {
+ public void testBug544073_058() {
runConformTest(
new String[] {
"X.java",
@@ -1992,7 +1988,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_059() {
+ public void testBug544073_059() {
runConformTest(
new String[] {
"X.java",
@@ -2013,7 +2009,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_060() {
+ public void testBug544073_060() {
runConformTest(
new String[] {
"X.java",
@@ -2034,7 +2030,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_061() {
+ public void testBug544073_061() {
runConformTest(
new String[] {
"X.java",
@@ -2055,7 +2051,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_062() {
+ public void testBug544073_062() {
runConformTest(
new String[] {
"X.java",
@@ -2076,7 +2072,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_063() {
+ public void testBug544073_063() {
runConformTest(
new String[] {
"X.java",
@@ -2097,7 +2093,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_064() {
+ public void testBug544073_064() {
runConformTest(
new String[] {
"X.java",
@@ -2128,7 +2124,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_065() {
+ public void testBug544073_065() {
runConformTest(
new String[] {
"X.java",
@@ -2154,7 +2150,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_066() {
+ public void testBug544073_066() {
runConformTest(
new String[] {
"X.java",
@@ -2178,7 +2174,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_067() {
+ public void testBug544073_067() {
runConformTest(
new String[] {
"X.java",
@@ -2206,7 +2202,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_068() {
+ public void testBug544073_068() {
runConformTest(
new String[] {
"X.java",
@@ -2231,7 +2227,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] {"--enable-preview"});
}
// see comment 12 in the bug
- public void _testBug544073_069() {
+ public void testBug544073_069() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2258,7 +2254,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"Type mismatch: cannot convert from Object to boolean\n" +
"----------\n");
}
- public void _testBug544073_070() {
+ public void testBug544073_070() {
runNegativeTest(
new String[] {
"X.java",
@@ -2291,7 +2287,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"A switch expression should have at least one result expression\n" +
"----------\n");
}
- public void _testBug544073_071() {
+ public void testBug544073_071() {
if (this.complianceLevel < ClassFileConstants.JDK12)
return;
Map<String, String> options = getCompilerOptions();
@@ -2327,7 +2323,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void _testBug544073_072() {
+ public void testBug544073_072() {
if (this.complianceLevel < ClassFileConstants.JDK12)
return;
Map<String, String> options = getCompilerOptions();
@@ -2358,7 +2354,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void _testBug544073_073() {
+ public void testBug544073_073() {
if (this.complianceLevel < ClassFileConstants.JDK1_8)
return;
Map<String, String> options = getCompilerOptions();
@@ -2389,7 +2385,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
new String[] { "--enable-preview"},
options);
}
- public void _testBug544073_074() {
+ public void testBug544073_074() {
runConformTest(
new String[] {
"X.java",
@@ -2412,7 +2408,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_075() {
+ public void testBug544073_075() {
runConformTest(
new String[] {
"X.java",
@@ -2435,7 +2431,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
null,
new String[] {"--enable-preview"});
}
- public void _testBug544073_076() {
+ public void testBug544073_076() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2467,7 +2463,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"'continue' or 'return' cannot be the last statement in a Switch expression case body\n" +
"----------\n");
}
- public void _testBug544073_077() {
+ public void testBug544073_077() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2499,7 +2495,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"'continue' or 'return' cannot be the last statement in a Switch expression case body\n" +
"----------\n");
}
- public void _testBug544073_078() {
+ public void testBug544073_078() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2526,7 +2522,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"Duplicate case\n" +
"----------\n");
}
- public void _testBug544073_079() {
+ public void testBug544073_079() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -2563,4 +2559,33 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"Duplicate case\n" +
"----------\n");
}
+ public void testBug544073_80() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "\n"+
+ "public class X {\n"+
+ "\n"+
+ " public static int yield() {\n"+
+ " return 1;\n"+
+ " }\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static int foo(int val) {\n"+
+ " return bar (switch (val) {\n"+
+ " case 1 : { yield val == 1 ? 2 : 3; }\n"+
+ " default : { yield 2; }\n"+
+ " });\n"+
+ " }\n"+
+ " public static int bar(int val) {\n"+
+ " return val;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(X.foo(1));\n"+
+ " }\n"+
+ "}\n"
+ },
+ "2",
+ null,
+ new String[] {"--enable-preview"});
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
index 80eecdce87..7df2d4e932 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
@@ -112,8 +112,10 @@ public String[] getCommandLine() {
long vmVersion = Util.getMajorMinorVMVersion();
if (vmVersion != -1) {
- if (vmVersion >= ClassFileConstants.JDK1_6) {
+ if (vmVersion < ClassFileConstants.JDK13) { // FailOverToOldVerifier deprecated from 13
commandLine.addElement("-XX:-FailOverToOldVerifier");
+ }
+ if (vmVersion >= ClassFileConstants.JDK1_6) {
commandLine.addElement("-Xverify:all");
}
if (vmVersion >= ClassFileConstants.JDK1_7) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
index ada2ae6b26..e5f345ae04 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BreakStatement.java
@@ -49,6 +49,9 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
return flowInfo; // pretend it did not break since no actual target
}
+ if (targetContext.associatedNode instanceof SwitchExpression) {
+ //TODO : flag error here currentScope.problemReporter().invalidBreak(this);
+ }
if ((this.isImplicit || this.switchExpression != null) && this.expression != null) {
flowInfo = this.expression.analyseCode(currentScope, flowContext, flowInfo);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index f32a048ec9..dcd50aa1e4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -159,6 +159,21 @@ public class SwitchStatement extends Expression {
complaintLevel = initialComplaintLevel; // reset complaint
fallThroughState = CASE;
} else {
+ if (i > 0 && !(this instanceof SwitchExpression) &&
+ currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK13 &&
+ statement instanceof BreakStatement &&
+ ((BreakStatement) statement).isImplicit) {
+ Statement prevStmt = this.statements[i - 1];
+ if (prevStmt instanceof Expression) {
+ Expression e = (Expression) prevStmt;
+ /* JLS 13 14.11.2
+ Switch labeled rules in switch statements differ from those in switch expressions (15.28).
+ In switch statements they must be switch labeled statement expressions, ... */
+ if (!e.statementExpression()) {
+ this.scope.problemReporter().invalidExpressionAsStatement(e);
+ }
+ }
+ }
fallThroughState = getFallThroughState(statement, currentScope); // reset below if needed
}
if ((complaintLevel = statement.complainIfUnreachable(caseInits, this.scope, complaintLevel, true)) < Statement.COMPLAINED_UNREACHABLE) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
index 4003385359..d05fbf49ac 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
@@ -26,6 +26,7 @@ public class YieldStatement extends BranchStatement {
public Expression expression;
public SwitchExpression switchExpression;
+ public boolean isImplicit;
public YieldStatement(Expression exp, int sourceStart, int e) {
super(null, sourceStart, e);
@@ -118,24 +119,13 @@ public void resolve(BlockScope scope) {
// METHOD IN WORKS - INCOMPLETE
super.resolve(scope);
// if (this.expression == null)
-// currentScope.problemReporter().yieldWithNullExpression(this);
+// currentScope.problemReporter().switchExpressionYieldMissingExpression(this);
//
//if (this.switchExpression == null)
// currentScope.problemReporter().yieldInNonSwitchExpression(this);
- if (this.expression != null && (this.switchExpression != null)) {
- if (this.switchExpression == null && !this.expression.statementExpression()) {
- if (scope.compilerOptions().enablePreviewFeatures) {
- /* JLS 12 14.11.2
- Switch labeled rules in switch statements differ from those in switch expressions (15.28).
- In switch statements they must be switch labeled statement expressions, ... */
- scope.problemReporter().invalidExpressionAsStatement(this.expression);
- return;
- }
- }
+ if (this.expression != null) {
this.expression.resolveType(scope);
- } else if (this.expression == null && this.switchExpression != null) {
- scope.problemReporter().switchExpressionBreakMissingValue(this);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
index c05672ebda..5717ced56a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java
@@ -1081,6 +1081,9 @@ public abstract class AbstractCommentParser implements JavadocTagConstants {
consumeToken();
break;
+ case TerminalTokens.TokenNameRestrictedIdentifierYield:
+ throw new InvalidInputException(); // unexpected.
+
case TerminalTokens.TokenNameDOT :
if ((iToken & 1) == 0) { // dots must be even tokens
throw new InvalidInputException();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index f8aba5abef..bd748e5713 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -943,6 +943,7 @@ protected int valueLambdaNestDepth = -1;
private int stateStackLengthStack[] = new int[0];
protected boolean parsingJava8Plus;
protected boolean parsingJava9Plus;
+protected boolean parsingJava13Plus;
protected boolean parsingJava12Plus;
protected boolean parsingJava11Plus;
protected int unstackedAct = ERROR_ACTION;
@@ -963,6 +964,7 @@ public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
initializeScanner();
this.parsingJava8Plus = this.options.sourceLevel >= ClassFileConstants.JDK1_8;
this.parsingJava9Plus = this.options.sourceLevel >= ClassFileConstants.JDK9;
+ this.parsingJava13Plus = this.options.sourceLevel >= ClassFileConstants.JDK13;
this.parsingJava12Plus = this.options.sourceLevel >= ClassFileConstants.JDK12;
this.parsingJava11Plus = this.options.sourceLevel >= ClassFileConstants.JDK11;
this.astLengthStack = new int[50];
@@ -9302,7 +9304,7 @@ protected void consumeStatementReturn() {
pushOnAstStack(new ReturnStatement(null, this.intStack[this.intPtr--], this.endStatementPosition));
}
}
-private void createSwitchStatementOrExpression(boolean isStmt) {
+private SwitchStatement createSwitchStatementOrExpression(boolean isStmt) {
//OpenBlock just makes the semantic action blockStart()
//the block is inlined but a scope need to be created
@@ -9330,11 +9332,13 @@ private void createSwitchStatementOrExpression(boolean isStmt) {
switchStatement.sourceEnd = this.endStatementPosition;
if (length == 0 && !containsComment(switchStatement.blockStart, switchStatement.sourceEnd)) {
switchStatement.bits |= ASTNode.UndocumentedEmptyBlock;
- }
+ }
+ return switchStatement;
}
protected void consumeStatementSwitch() {
// SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
- createSwitchStatementOrExpression(true);
+ SwitchStatement s = createSwitchStatementOrExpression(true);
+ replaceYield(s);
}
protected void consumeStatementSynchronized() {
// SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
@@ -9666,6 +9670,70 @@ protected void consumeDefaultLabelExpr() {
stmt.traverse(reCollector, null);
}
}
+/* package */ void flagBreak(SwitchExpression s) {
+ if (s.resultExpressions != null)
+ return; // already calculated.
+
+ class BreakFlagVisitor extends ASTVisitor {
+ Stack<SwitchExpression> targetSwitchExpressions;
+ public BreakFlagVisitor(SwitchExpression se) {
+ if (this.targetSwitchExpressions == null)
+ this.targetSwitchExpressions = new Stack<>();
+ this.targetSwitchExpressions.push(se);
+ }
+ @Override
+ public boolean visit(SwitchExpression switchExpression, BlockScope blockScope) {
+ if (switchExpression.resultExpressions == null)
+ switchExpression.resultExpressions = new ArrayList<>(0);
+ this.targetSwitchExpressions.push(switchExpression);
+ return false;
+ }
+ @Override
+ public void endVisit(SwitchExpression switchExpression, BlockScope blockScope) {
+ this.targetSwitchExpressions.pop();
+ }
+ @Override
+ public boolean visit(BreakStatement breakStatement, BlockScope blockScope) {
+ // flag an error while resolving
+ breakStatement.switchExpression = this.targetSwitchExpressions.peek();
+ return true;
+ }
+ @Override
+ public boolean visit(DoStatement stmt, BlockScope blockScope) {
+ return false;
+ }
+ @Override
+ public boolean visit(ForStatement stmt, BlockScope blockScope) {
+ return false;
+ }
+ @Override
+ public boolean visit(ForeachStatement stmt, BlockScope blockScope) {
+ return false;
+ }
+ @Override
+ public boolean visit(SwitchStatement stmt, BlockScope blockScope) {
+ return false;
+ }
+ @Override
+ public boolean visit(TypeDeclaration stmt, BlockScope blockScope) {
+ return false;
+ }
+ @Override
+ public boolean visit(WhileStatement stmt, BlockScope blockScope) {
+ return false;
+ }
+ @Override
+ public boolean visit(CaseStatement caseStatement, BlockScope blockScope) {
+ return true; // do nothing by default, keep traversing
+ }
+ }
+ int l = s.statements == null ? 0 : s.statements.length;
+ for (int i = 0; i < l; ++i) {
+ Statement stmt = s.statements[i];
+ BreakFlagVisitor reCollector = new BreakFlagVisitor(s);
+ stmt.traverse(reCollector, null);
+ }
+}
/* package */ void collectResultExpressionsYield(SwitchExpression s) {
if (s.resultExpressions != null)
return; // already calculated.
@@ -9750,6 +9818,29 @@ protected void consumeDefaultLabelExpr() {
stmt.traverse(reCollector, null);
}
}
+/* package */ void replaceYield(SwitchStatement s) {
+ if (!this.parsingJava13Plus)
+ return;
+ int l = s.statements == null ? 0 : s.statements.length;
+ List<Statement> tmp = new ArrayList<>(l);
+ for (int i = 0; i < l; ++i) {
+ //TODO: add opt for lazy init
+ Statement stmt = s.statements[i];
+ if (stmt instanceof YieldStatement) {
+ Expression e = ((YieldStatement) stmt).expression;
+ tmp.add(e);
+ BreakStatement b = new BreakStatement(null, -1, -1);
+ b.isImplicit = true;
+ tmp.add(b);
+ } else {
+ tmp.add(stmt);
+ }
+ }
+ int sztmp = tmp.size();
+ if (sztmp > l) {
+ s.statements = tmp.toArray(new Statement[]{});
+ }
+}
protected void consumeSwitchExpression() {
// SwitchExpression ::= 'switch' '(' Expression ')' OpenBlock SwitchExpressionBlock
createSwitchStatementOrExpression(false);
@@ -9797,13 +9888,12 @@ protected void consumeSwitchLabeledRuleToBlockStatement() {
protected void consumeSwitchLabeledExpression() {
consumeExpressionStatement();
Expression expr = (Expression) this.astStack[this.astPtr];
- BreakStatement breakStatement = new BreakStatement(
- null,
+ YieldStatement yieldStatement = new YieldStatement(
+ expr,
expr.sourceStart,
this.endStatementPosition);
- breakStatement.isImplicit = true;
- breakStatement.expression = expr;
- this.astStack[this.astPtr] = breakStatement;
+ yieldStatement.isImplicit = true;
+ this.astStack[this.astPtr] = yieldStatement;
concatNodeLists();
}
protected void consumeSwitchLabeledBlock() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 8d0a1c2f62..44c96a5d44 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -2568,7 +2568,8 @@ public boolean isInModuleDeclaration() {
(this.activeParser != null ? this.activeParser.isParsingModuleDeclaration() : false);
}
protected boolean areRestrictedModuleKeywordsActive() {
- return this.scanContext != null && this.scanContext != ScanContext.INACTIVE;
+ return this.scanContext != null && this.scanContext != ScanContext.INACTIVE &&
+ this.scanContext != ScanContext.EXPECTING_YIELD;
}
void updateScanContext(int token) {
switch (token) {
@@ -4122,6 +4123,8 @@ public String toStringAction(int act) {
switch (act) {
case TokenNameIdentifier :
return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameRestrictedIdentifierYield :
+ return "yield"; //$NON-NLS-1$
case TokenNameabstract :
return "abstract"; //$NON-NLS-1$
case TokenNameboolean :
@@ -4441,6 +4444,9 @@ public static boolean isKeyword(int token) {
case TerminalTokens.TokenNamevolatile:
case TerminalTokens.TokenNamewhile:
return true;
+ case TerminalTokens.TokenNameRestrictedIdentifierYield:
+ // making explicit - yield not a (restricted) keyword but restricted identifier.
+ //$FALL-THROUGH$
default:
return false;
}
@@ -4813,16 +4819,12 @@ public static boolean isRestrictedKeyword(int token) {
}
private boolean mayBeAtAnYieldStatement() {
// preceded by ;, {, }, ), or -> [Ref: http://mail.openjdk.java.net/pipermail/amber-spec-experts/2019-May/001401.html]
+ // above comment is super-seded by http://mail.openjdk.java.net/pipermail/amber-spec-experts/2019-May/001414.html
switch (this.lookBack[1]) {
- case TokenNameSEMICOLON:
- case TokenNameLBRACE:
- case TokenNameRBRACE:
- case TokenNameLBRACKET:
- case TokenNameRBRACKET:
- case TokenNameARROW:
- return true;
- default:
+ case TokenNameDOT:
return false;
+ default:
+ return true;
}
}
int disambiguatedRestrictedIdentifier(int restrictedKeywordToken) {
@@ -4995,6 +4997,7 @@ public int fastForward(Statement unused) {
case TokenNameAT:
case TokenNameBeginLambda:
case TokenNameAT308:
+ case TokenNameRestrictedIdentifierYield: // can be in FOLLOW of Block
if(getVanguardParser().parse(Goal.BlockStatementoptGoal) == VanguardParser.SUCCESS)
return token;
break;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index 496ceb709b..3c3b096560 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -5089,6 +5089,9 @@ private boolean isKeyword(int token) {
case TerminalTokens.TokenNamevolatile:
case TerminalTokens.TokenNamewhile:
return true;
+ case TerminalTokens.TokenNameRestrictedIdentifierYield:
+ // making explicit - yield not a (restricted) keyword but restricted identifier.
+ //$FALL-THROUGH$
default:
return false;
}

Back to the top