diff options
author | Manoj Palat | 2020-07-02 13:48:20 +0000 |
---|---|---|
committer | Manoj Palat | 2020-07-02 13:51:12 +0000 |
commit | 6143bacb920e046f7b73ecd8f4403bf8a02ce709 (patch) | |
tree | 817c22224c5232fe1374c7b0cd2f5b7acfd2da34 | |
parent | 7ac4eb5ecc4cfd6027991285e78ba450dfbcd7e1 (diff) | |
download | eclipse.jdt.core-6143bacb920e046f7b73ecd8f4403bf8a02ce709.tar.gz eclipse.jdt.core-6143bacb920e046f7b73ecd8f4403bf8a02ce709.tar.xz eclipse.jdt.core-6143bacb920e046f7b73ecd8f4403bf8a02ce709.zip |
Change-Id: I829e6c05cdad709b38d538a410f3e6e18bf7d6d3
Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
10 files changed, 1776 insertions, 25 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java index 3ce86b51ff..755e274e67 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java @@ -1277,7 +1277,7 @@ public void test011_problem_categories() { expectedProblemAttributes.put("SealedNotDirectSuperInterface", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED)); expectedProblemAttributes.put("SealedLocalDirectSuperTypeSealed", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED)); expectedProblemAttributes.put("SealedAnonymousClassCannotExtendSealedType", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED)); - + expectedProblemAttributes.put("SealedPermitsIsReservedTypeName", new ProblemAttributes(CategorizedProblem.CAT_PREVIEW_RELATED)); StringBuffer failures = new StringBuffer(); StringBuffer correctResult = new StringBuffer(70000); Field[] fields = (iProblemClass = IProblem.class).getFields(); @@ -2324,6 +2324,7 @@ public void test012_compiler_problems_tuning() { expectedProblemAttributes.put("SealedNotDirectSuperInterface", SKIP); expectedProblemAttributes.put("SealedLocalDirectSuperTypeSealed", SKIP); expectedProblemAttributes.put("SealedAnonymousClassCannotExtendSealedType", SKIP); + expectedProblemAttributes.put("SealedPermitsIsReservedTypeName", SKIP); Map constantNamesIndex = new HashMap(); Field[] fields = JavaCore.class.getFields(); for (int i = 0, length = fields.length; i < length; i++) { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java index 6c10841dae..b99e667dd6 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java @@ -33,7 +33,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug563184"}; +// TESTS_NAMES = new String[] { "testBug550750"}; } public static Class<?> testClass() { @@ -728,7 +728,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { }, "0"); } - public void _testBug550750_032() { + public void testBug550750_032() { this.runNegativeTest( new String[] { "X.java", @@ -745,7 +745,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { "Record is a restricted identifier and hence not a valid type name\n" + "----------\n"); } - public void _testBug550750_033() { + public void testBug550750_033() { this.runNegativeTest( new String[] { "X.java", @@ -762,7 +762,7 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { "Record is a restricted identifier and hence not a valid type name\n" + "----------\n"); } - public void _testBug550750_034() { + public void testBug550750_034() { this.runNegativeTest( new String[] { "X.java", @@ -778,9 +778,14 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { " public <record> void foo(record args){}\n" + " ^^^^^^\n" + "Record is a restricted identifier and hence not a valid type name\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " public <record> void foo(record args){}\n" + + " ^^^^^^\n" + + "Record is a restricted identifier and hence not a valid type name\n" + "----------\n"); } - public void _testBug550750_035() { + public void testBug550750_035() { this.runNegativeTest( new String[] { "X.java", @@ -795,15 +800,10 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { "1. ERROR in X.java (at line 5)\n" + " public void foo(record args){}\n" + " ^^^^^^\n" + - "record cannot be resolved to a type\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " public void foo(record args){}\n" + - " ^^^^^^\n" + "Record is a restricted identifier and hence not a valid type name\n" + "----------\n"); } - public void _testBug550750_036() { + public void testBug550750_036() { this.runNegativeTest( new String[] { "X.java", @@ -826,11 +826,6 @@ public class RecordsRestrictedClassTest extends AbstractRegressionTest { "2. ERROR in X.java (at line 4)\n" + " I lambda = (record r) -> {};\n" + " ^^^^^^\n" + - "record cannot be resolved to a type\n" + - "----------\n" + - "3. ERROR in X.java (at line 4)\n" + - " I lambda = (record r) -> {};\n" + - " ^^^^^^\n" + "Record is a restricted identifier and hence not a valid type name\n" + "----------\n"); } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java index 8f47f3b3fd..0e37bbaa9d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java @@ -35,7 +35,7 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 { static { // TESTS_NUMBERS = new int [] { 40 }; // TESTS_RANGE = new int[] { 1, -1 }; -// TESTS_NAMES = new String[] { "testBug564498_1"}; +// TESTS_NAMES = new String[] { "testBug564638"}; } public static Class<?> testClass() { @@ -1667,4 +1667,1727 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 { "Syntax error on token \"permits\", delete this token\n" + "----------\n"); } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_001() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class permits {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type permits\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_002() { + runNegativeTest( + new String[] { + "X.java", + "class permits {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type permits\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_003() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " permits p;\n" + + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + "permits.java", + "public class permits {\n"+ + "}", + }, + "----------\n" + + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " permits p;\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "----------\n" + + "1. WARNING in permits.java (at line 1)\n" + + " public class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_004() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " permits p;\n" + + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + "permits.java", + "public class permits {\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " permits p;\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "----------\n" + + "1. ERROR in permits.java (at line 1)\n" + + " public class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_005() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X<permits> {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " class X<permits> {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X<permits>\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_006() { + runNegativeTest( + new String[] { + "X.java", + "class X<permits> {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " class X<permits> {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X<permits>\n" + + "----------\n"); + } + public void testBug564638_007() { + runNegativeTest( + new String[] { + "X.java", + "class X extends permits {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "class permits {\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " class X extends permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_008() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X extends permits {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "class permits {\n"+ + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " class X extends permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_009() { + runNegativeTest( + new String[] { + "X.java", + "class X implements permits {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "interface permits {\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " class X implements permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " interface permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_010() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X implements permits {\n"+ + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "interface permits {\n"+ + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " class X implements permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " interface permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_011() { + runNegativeTest( + new String[] { + "X.java", + "interface X extends permits {\n"+ + " default void foo() {\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "interface permits {\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " interface X extends permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " interface permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_012() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "interface X extends permits {\n"+ + " default void foo() {\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "interface permits {\n"+ + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " interface X extends permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "3. WARNING in X.java (at line 6)\n" + + " interface permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_013() { + runNegativeTest( + new String[] { + "X.java", + "class X extends {\n"+ + " permits foo() {\n" + + " Zork();\n" + + " return null;\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " class X extends {\n" + + " ^^^^^^^\n" + + "Syntax error on token \"extends\", Type expected after this token\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " permits foo() {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_014() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " permits foo() {\n" + + " Zork();\n" + + " return null;\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " permits foo() {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " permits foo() {\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_015() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " void foo() throws permits{\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo() throws permits{\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_016() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " void foo() throws permits{\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " void foo() throws permits{\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo() throws permits{\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_017() { + runNegativeTest( + new String[] { + "X.java", + "class X <T extends permits> {\n"+ + " <T> void foo(T extends permits) {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " class X <T extends permits> {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " class X <T extends permits> {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "3. WARNING in X.java (at line 2)\n" + + " <T> void foo(T extends permits) {\n" + + " ^\n" + + "The type parameter T is hiding the type T\n" + + "----------\n" + + "4. ERROR in X.java (at line 2)\n" + + " <T> void foo(T extends permits) {\n" + + " ^^^^^^^\n" + + "Syntax error on token \"extends\", delete this token\n" + + "----------\n" + + "5. ERROR in X.java (at line 5)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_018() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X <T extends permits>{\n"+ + " <T> void foo(T extends permits) {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " class X <T extends permits>{\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " class X <T extends permits>{\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 1)\n" + + " class X <T extends permits>{\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "4. WARNING in X.java (at line 2)\n" + + " <T> void foo(T extends permits) {\n" + + " ^\n" + + "The type parameter T is hiding the type T\n" + + "----------\n" + + "5. ERROR in X.java (at line 2)\n" + + " <T> void foo(T extends permits) {\n" + + " ^^^^^^^\n" + + "Syntax error on token \"extends\", delete this token\n" + + "----------\n" + + "6. ERROR in X.java (at line 5)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_019() { + runNegativeTest( + new String[] { + "X.java", + "enum X {\n"+ + " ONE(1);\n" + + " private final permits p;\n" + + " X(int p) {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " private final permits p;\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_020() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "enum X {\n"+ + " ONE(1);\n" + + " private final permits p;\n" + + " X(int p) {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " private final permits p;\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " private final permits p;\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_021() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n" + + " I i = (permits p)-> {};\n" + +// " Zork();\n" + + " }\n" + + "}\n" + + "interface I {\n" + + " void apply(Object o);\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " I i = (permits p)-> {};\n" + + " ^^^^^^^^^^^^^\n" + + "This lambda expression refers to the missing type permits\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " I i = (permits p)-> {};\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_022() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n" + + " I i = (permits p)-> {};\n" + + " Zork();\n" + + " }\n" + + "}\n" + + "interface I {\n" + + " void apply(Object o);\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " I i = (permits p)-> {};\n" + + " ^^^^^^^^^^^^^\n" + + "This lambda expression refers to the missing type permits\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " I i = (permits p)-> {};\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " I i = (permits p)-> {};\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "4. ERROR in X.java (at line 4)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_023() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public void foo(permits this) {}\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_024() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public void foo(permits this) {}\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_025() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public void foo(permits this) {}\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_026() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public void foo(permits this) {}\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_027() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " class permits {\n"+ + " public void foo(permits this) {}\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_028() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " class permits {\n"+ + " public void foo(permits this) {}\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " public void foo(permits this) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_029() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n" + + " permits p;\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " permits p;\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_030() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n" + + " permits p;\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " permits p;\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " permits p;\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_031() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n" + + " for (permits i = 0; i < 10; ++i) {} \n" + + " }\n" + + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for (permits i = 0; i < 10; ++i) {} \n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_032() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n" + + " for (permits i = 0; i < 10; ++i) {} \n" + + " }\n" + + " void foo() {\n" + + " Zork();\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " for (permits i = 0; i < 10; ++i) {} \n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " for (permits i = 0; i < 10; ++i) {} \n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_033() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(permits[] args) {\n" + + " for (permits p : args) {} \n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public static void main(permits[] args) {\n" + + " ^^^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " for (permits p : args) {} \n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_034() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(permits[] args) {\n" + + " for (permits p : args) {} \n" + + " }\n" + + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " public static void main(permits[] args) {\n" + + " ^^^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public static void main(permits[] args) {\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. WARNING in X.java (at line 3)\n" + + " for (permits p : args) {} \n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "4. ERROR in X.java (at line 3)\n" + + " for (permits p : args) {} \n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_035() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " try (permits y = new Y()) {\n"+ + " \n"+ + " } catch (Exception e) {\n"+ + " e.printStackTrace();\n"+ + " } finally {\n"+ + " \n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "class Y implements AutoCloseable {\n"+ + " @Override\n"+ + " public void close() throws Exception {}\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " try (permits y = new Y()) {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_036() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " try (permits y = new Y()) {\n"+ + " \n"+ + " } catch (Exception e) {\n"+ + " e.printStackTrace();\n"+ + " } finally {\n"+ + " \n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "class Y implements AutoCloseable {\n"+ + " @Override\n"+ + " public void close() throws Exception {}\n"+ + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " try (permits y = new Y()) {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " try (permits y = new Y()) {\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_037() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " try (Y y = new Y()) {\n"+ + " \n"+ + " } catch (permits e) {\n"+ + " e.printStackTrace();\n"+ + " } finally {\n"+ + " \n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "class Y implements AutoCloseable {\n"+ + " @Override\n"+ + " public void close() throws Exception {}\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " } catch (permits e) {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_038() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " try (Y y = new Y()) {\n"+ + " \n"+ + " } catch (permits e) {\n"+ + " e.printStackTrace();\n"+ + " } finally {\n"+ + " \n"+ + " }\n"+ + " }\n"+ + "}\n"+ + "class Y implements AutoCloseable {\n"+ + " @Override\n"+ + " public void close() throws Exception {}\n"+ + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 5)\n" + + " } catch (permits e) {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " } catch (permits e) {\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_039() { + runNegativeTest( + new String[] { + "X.java", + "record X(permits p) {\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " record X(permits p) {\n" + + " ^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " record X(permits p) {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_040() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "record X(permits p) {\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " record X(permits p) {\n" + + " ^^^^^^\n" + + "record is a preview feature and disabled by default. Use --enable-preview to enable\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_041() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> X(T t) {}\n"+ + " \n"+ + " public X(int t, char c) {\n"+ + " <permits>this(t);\n"+ + " }\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " <permits>this(t);\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " <permits>this(t);\n" + + " ^^^^^^^^\n" + + "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_042() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> X(T t) {}\n"+ + " \n"+ + " public X(int t, char c) {\n"+ + " <permits>this(t);\n"+ + " }\n"+ + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 5)\n" + + " <permits>this(t);\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " <permits>this(t);\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " <permits>this(t);\n" + + " ^^^^^^^^\n" + + "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_043() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> X(T t) {}\n"+ + " \n"+ + " public X(int t, char c) {\n"+ + " new <permits>X(t).foo();\n"+ + " }\n"+ + " public void foo() {}\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " new <permits>X(t).foo();\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " new <permits>X(t).foo();\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_044() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> X(T t) {}\n"+ + " \n"+ + " public X(int t, char c) {\n"+ + " new <permits>X(t).foo();\n"+ + " }\n"+ + " public void foo() {}\n"+ + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " new <permits>X(t).foo();\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "The parameterized constructor <permits>X(permits) of type X is not applicable for the arguments (Integer)\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " new <permits>X(t).foo();\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " new <permits>X(t).foo();\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_045() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> void foo(T t) {}\n"+ + " \n"+ + " public X() {\n"+ + " X x = new X();\n"+ + " x.<permits>foo(0);\n"+ + " }\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " x.<permits>foo(0);\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " x.<permits>foo(0);\n" + + " ^^^\n" + + "The parameterized method <permits>foo(permits) of type X is not applicable for the arguments (Integer)\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_046() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> void foo(T t) {}\n"+ + " \n"+ + " public X() {\n"+ + " X x = new X();\n"+ + " x.<permits>foo(0);\n"+ + " }\n"+ + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " x.<permits>foo(0);\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " x.<permits>foo(0);\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 6)\n" + + " x.<permits>foo(0);\n" + + " ^^^\n" + + "The parameterized method <permits>foo(permits) of type X is not applicable for the arguments (Integer)\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_047() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> void foo(T t) {}\n"+ + " \n"+ + " public X() {\n"+ + " X x = new permits();\n"+ + " }\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " X x = new permits();\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_048() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public <T> void foo(T t) {}\n"+ + " \n"+ + " public X() {\n"+ + " X x = new permits();\n"+ + " }\n"+ + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 5)\n" + + " X x = new permits();\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " X x = new permits();\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_049() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public X() {\n"+ + " new permits() {\n"+ + " @Override\n"+ + " void foo() {}\n"+ + " }.foo();\n"+ + " }\n"+ + "}\n"+ + "abstract class permits {\n"+ + " abstract void foo();\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new permits() {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " abstract class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_050() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public X() {\n"+ + " new permits() {\n"+ + " @Override\n"+ + " void foo() {\n"+ + " Zork();\n"+ + " }\n"+ + " }.foo();\n"+ + " }\n"+ + "}\n"+ + "abstract class permits {\n"+ + " abstract void foo();\n"+ + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " new permits() {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type new permits(){}\n" + + "----------\n" + + "3. WARNING in X.java (at line 11)\n" + + " abstract class permits {\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_051() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public X() {\n"+ + " Object[] p = new permits[10];\n"+ + " }\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Object[] p = new permits[10];\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_052() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public X() {\n"+ + " Object[] p = new permits[10];\n"+ + " }\n"+ + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " Object[] p = new permits[10];\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " Object[] p = new permits[10];\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_053() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " new X().foo((permits) null);\n"+ + " }\n"+ + " private void foo(permits o) {}\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new X().foo((permits) null);\n" + + " ^^^\n" + + "The method foo(permits) from the type X refers to the missing type permits\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " new X().foo((permits) null);\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " private void foo(permits o) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_054() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " new X().foo((permits) null);\n"+ + " }\n"+ + " private void foo(permits o) {}\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new X().foo((permits) null);\n" + + " ^^^\n" + + "The method foo(permits) from the type X refers to the missing type permits\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " new X().foo((permits) null);\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " new X().foo((permits) null);\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n" + + "4. WARNING in X.java (at line 5)\n" + + " private void foo(permits o) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "5. ERROR in X.java (at line 5)\n" + + " private void foo(permits o) {}\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_055() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " private void foo(Object o) {\n"+ + " if (o instanceof permits) {}\n"+ + " }\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " if (o instanceof permits) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_056() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " private void foo(Object o) {\n"+ + " if (o instanceof permits) {}\n"+ + " }\n"+ + "}", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " if (o instanceof permits) {}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " if (o instanceof permits) {}\n" + + " ^^^^^^^\n" + + "permits cannot be resolved to a type\n" + + "----------\n", + null, + true, + options + ); + } + public void testBug564638_057() { + runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " @SuppressWarnings(\"unused\")\n"+ + " I i = permits :: new;\n"+ + " Zork();\n"+ + " }\n"+ + "}\n"+ + "class permits{}\n" + + "interface I {\n"+ + " Object gen();\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " class permits{}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n"); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void testBug564638_058() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_EnablePreviews, CompilerOptions.DISABLED); + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n"+ + " public static void main(String[] args) {\n"+ + " @SuppressWarnings(\"unused\")\n"+ + " I i = permits :: new;\n"+ + " Zork();\n"+ + " }\n"+ + "}\n"+ + "class permits{}\n" + + "interface I {\n"+ + " Object gen();\n"+ + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " Zork();\n" + + " ^^^^\n" + + "The method Zork() is undefined for the type X\n" + + "----------\n" + + "2. WARNING in X.java (at line 8)\n" + + " class permits{}\n" + + " ^^^^^^^\n" + + "\'permits\' is not a valid type name; it is a reserved type word in Java 15 with preview enabled\n" + + "----------\n", + null, + true, + options + ); + } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java index e9662d0739..2319f443e7 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java @@ -2404,6 +2404,9 @@ void setSourceStart(int sourceStart); /** @since 3.22 BETA_JAVA15 * @noreference preview feature error */ int SealedAnonymousClassCannotExtendSealedType = PreviewRelated + 1865; + /** @since 3.22 BETA_JAVA15 + * @noreference preview feature error */ + int SealedPermitsIsReservedTypeName = PreviewRelated + 1866; /* Java15 errors - end */ } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java index c398c9a484..c9b73bc9e0 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java @@ -312,12 +312,24 @@ public void analyseCode(CompilationUnitScope unitScope) { } } -public static void checkAndFlagRecordNameErrors(char[] typeName, ASTNode node, Scope skope) { +/** + * returns true if an error is flagged, false if either no error was flagged + * or only a warning was flagged. + */ +public static boolean checkAndFlagType15NameErrors(char[] typeName, ASTNode node, Scope skope) { + boolean isPreviewEnabled = skope.compilerOptions().enablePreviewFeatures; if (CharOperation.equals(typeName, TypeConstants.RECORD_RESTRICTED_IDENTIFIER)) { - if (skope.compilerOptions().sourceLevel == ClassFileConstants.JDK14) { + if (skope.compilerOptions().sourceLevel >= ClassFileConstants.JDK15) { skope.problemReporter().recordIsAReservedTypeName(node); + return isPreviewEnabled; + } + } else if (CharOperation.equals(typeName, TypeConstants.PERMITS)) { + if (skope.compilerOptions().sourceLevel >= ClassFileConstants.JDK15) { + skope.problemReporter().sealedPermitsIsReservedTypeName(node); + return isPreviewEnabled; } } + return false; } /** @@ -1309,7 +1321,7 @@ public void resolve() { this.scope.problemReporter().varIsReservedTypeName(this); } } - TypeDeclaration.checkAndFlagRecordNameErrors(this.name, this, this.scope); + TypeDeclaration.checkAndFlagType15NameErrors(this.name, this, this.scope); // resolve annotations and check @Deprecated annotation long annotationTagBits = sourceType.getAnnotationTagBits(); if ((annotationTagBits & TagBits.AnnotationDeprecated) == 0 diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java index 6093947822..ed931452ea 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java @@ -124,7 +124,7 @@ public class TypeParameter extends AbstractVariableDeclaration { scope.problemReporter().varIsNotAllowedHere(this); } } - TypeDeclaration.checkAndFlagRecordNameErrors(this.name, this, scope); + TypeDeclaration.checkAndFlagType15NameErrors(this.name, this, scope); } @Override diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java index 68f8fcc406..f96e7bd187 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java @@ -536,17 +536,16 @@ protected TypeBinding internalResolveType(Scope scope, int location) { } } } - boolean hasError; + boolean hasError = false; TypeBinding type = this.resolvedType = getTypeBinding(scope); if (type == null) { return null; // detected cycle while resolving hierarchy } else if ((hasError = !type.isValidBinding()) == true) { if (this.isTypeNameVar(scope)) { reportVarIsNotAllowedHere(scope); - } else { + } else if (!TypeDeclaration.checkAndFlagType15NameErrors(getTypeName(0), this, scope)) { reportInvalidType(scope); } - TypeDeclaration.checkAndFlagRecordNameErrors(getTypeName(0), this, scope); switch (type.problemId()) { case ProblemReasons.NotFound : case ProblemReasons.NotVisible : @@ -557,6 +556,8 @@ protected TypeBinding internalResolveType(Scope scope, int location) { default : return null; } + } else { // check anyway - to cover a illegally declared "permits" type + TypeDeclaration.checkAndFlagType15NameErrors(getTypeName(0), this, scope); } if (type.isArrayType() && ((ArrayBinding) type).leafComponentType == TypeBinding.VOID) { scope.problemReporter().cannotAllocateVoidArray(this); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java index 9053c23bb0..6afb8441b3 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java @@ -8,6 +8,10 @@ * * SPDX-License-Identifier: EPL-2.0 * + * This is an implementation of an early-draft specification developed under the Java + * Community Process (JCP) and is made available for testing and evaluation purposes + * only. The code is not compatible with any specification of the JCP. + * * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann - Contributions for @@ -120,6 +124,8 @@ public interface TypeConstants { // JEP 359 Records char[] RECORD_RESTRICTED_IDENTIFIER = "record".toCharArray(); //$NON-NLS-1$ char[] RECORD_CLASS = "Record".toCharArray(); //$NON-NLS-1$ + // JEP 360 Sealed + char[] PERMITS = "permits".toCharArray(); //$NON-NLS-1$ // jsr308 char[] TYPE_USE_TARGET = "TYPE_USE".toCharArray(); //$NON-NLS-1$ 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 dd9da26ef9..5b7c56ac74 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 @@ -12044,4 +12044,13 @@ public void sealedAnonymousClassCannotExtendSealedType(TypeReference reference, reference.sourceStart, reference.sourceEnd); } +public void sealedPermitsIsReservedTypeName(ASTNode node) { + this.handle( + IProblem.SealedPermitsIsReservedTypeName, + NoArgument, + NoArgument, + this.options.enablePreviewFeatures ? ProblemSeverities.Error | ProblemSeverities.Fatal : ProblemSeverities.Warning, + node.sourceStart, + node.sourceEnd); +} }
\ No newline at end of file diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties index 8ada8f2c7a..88d4873987 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties @@ -1094,6 +1094,7 @@ 1863 = Permitted type {0} does not declare {1} as direct super interface 1864 = A local class {1} cannot have a sealed direct superclass or a sealed direct superinterface {0} 1865 = An anonymous class cannot subclass a sealed type {0} +1866 = 'permits' is not a valid type name; it is a reserved type word in Java 15 with preview enabled # Java 15 Preview - end |