Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-07-29 01:03:56 -0400
committerManoj Palat2020-07-29 01:03:56 -0400
commiteacc7a968e5b57af79ddde8ef2755a930c882050 (patch)
tree7fc8bda0a4811659e91d323eee49917140c4daf9
parent48a32cdd1476a0f352acd764ab267163fc4183b1 (diff)
downloadeclipse.jdt.core-eacc7a968e5b57af79ddde8ef2755a930c882050.tar.gz
eclipse.jdt.core-eacc7a968e5b57af79ddde8ef2755a930c882050.tar.xz
eclipse.jdt.core-eacc7a968e5b57af79ddde8ef2755a930c882050.zip
Bug 565116 - [15] sealed types - incorrect permits not allowed errorY20200729-0630
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypes15Tests.java15
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java4
2 files changed, 16 insertions, 3 deletions
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 fd68bcd908..1fb26edc98 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[] { "testBug564638"};
+// TESTS_NAMES = new String[] { "testBug565116_001"};
}
public static Class<?> testClass() {
@@ -5137,4 +5137,17 @@ public class SealedTypes15Tests extends AbstractRegressionTest9 {
"}";
verifyClassFile(expectedOutput, "X.class", ClassFileBytesDisassembler.SYSTEM);
}
+ public void testBug565116_001() throws IOException, ClassFormatException {
+ runConformTest(
+ new String[] {
+ "permits/X.java",
+ "package permits;\n"+
+ "class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " X x = new permits.X();\n"+
+ " }\n"+
+ "}",
+ },
+ "");
+ }
}
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 8708a5dce8..7fda39b1ea 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
@@ -543,7 +543,7 @@ protected TypeBinding internalResolveType(Scope scope, int location) {
} else if ((hasError = !type.isValidBinding()) == true) {
if (this.isTypeNameVar(scope)) {
reportVarIsNotAllowedHere(scope);
- } else if (!scope.problemReporter().validateRestrictedKeywords(getTypeName(0), this)) {
+ } else if (!scope.problemReporter().validateRestrictedKeywords(getLastToken(), this)) {
reportInvalidType(scope);
}
switch (type.problemId()) {
@@ -557,7 +557,7 @@ protected TypeBinding internalResolveType(Scope scope, int location) {
return null;
}
} else { // check anyway - to cover a illegally declared "permits" type
- scope.problemReporter().validateRestrictedKeywords(getTypeName(0), this);
+ scope.problemReporter().validateRestrictedKeywords(getLastToken(), this);
}
if (type.isArrayType() && ((ArrayBinding) type).leafComponentType == TypeBinding.VOID) {
scope.problemReporter().cannotAllocateVoidArray(this);

Back to the top