Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2017-07-09 15:55:39 +0000
committerTill Brychcy2017-10-10 15:56:14 +0000
commit30089883a917eade20b36479b5c83c148ec35e5a (patch)
treec2ba38ffe40374ecae0b96c38659d9a61a14d98c
parent93cabc2b1a6103f5b8fc5e200336888a24a95ba5 (diff)
downloadeclipse.jdt.core-30089883a917eade20b36479b5c83c148ec35e5a.tar.gz
eclipse.jdt.core-30089883a917eade20b36479b5c83c148ec35e5a.tar.xz
eclipse.jdt.core-30089883a917eade20b36479b5c83c148ec35e5a.zip
Bug 518157 - A Class<? extends RawType> = Impl.class where RawType is a
nested interface within a generic class fails compilation Change-Id: I39f7056e4866ee71744e84ac06a07ca7ea335d5c
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java37
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java24
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java3
5 files changed, 59 insertions, 12 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
index 632fb8280b..7e34a8f2d0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -6122,6 +6122,43 @@ public void testBug515614() {
}
);
}
+public void testBug518157A() {
+ runConformTest(
+ new String[] {
+ "RawClassParameterizationBug.java",
+ "class RawClassParameterizationBug<Oops> {\n" +
+ "\n" +
+ " public interface Example<K,V> {\n" +
+ " }\n" +
+ " \n" +
+ " public static class DefaultExample<K,V> implements Example<K,V> {\n" +
+ " }\n" +
+ " @SuppressWarnings(\"rawtypes\")\n" +
+ " static final Class<? extends Example> fails = DefaultExample.class;\n" +
+ "}\n" +
+ "",
+ }
+ );
+}
+public void testBug518157B() {
+ runConformTest(
+ new String[] {
+ "AlternateRawClassParameterizationBug.java",
+ "import java.util.Map;\n" +
+ "\n" +
+ "class AlternateRawClassParameterizationBug {\n" +
+ "\n" +
+ " abstract static class MapEntry<K,V> implements Map.Entry<K, V> {\n" +
+ " }\n" +
+ "\n" +
+ " @SuppressWarnings(\"rawtypes\")\n" +
+ " static final Class<? extends Map.Entry> mapFails = MapEntry.class;\n" +
+ "\n" +
+ "}\n" +
+ "",
+ }
+ );
+}
public void testBug521212() {
runNegativeTest(
new String[] {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java
index 54d0a7a2d4..ecc018eac0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotatableTypeSystem.java
@@ -157,6 +157,9 @@ public class AnnotatableTypeSystem extends TypeSystem {
if (!haveTypeAnnotations(genericType, enclosingType, null, annotations))
return nakedType;
+ if(genericType.isStatic() && enclosingType != null) {
+ enclosingType=(ReferenceBinding) enclosingType.original();
+ }
RawTypeBinding rawType = new RawTypeBinding(genericType, enclosingType, this.environment);
rawType.id = nakedType.id;
rawType.setTypeAnnotations(annotations, this.isAnnotationBasedNullAnalysisEnabled);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index 70546c2aa9..9d71f76279 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -848,20 +848,24 @@ public TypeBinding convertToRawType(TypeBinding type, boolean forceRawEnclosingT
convertedType = needToConvert ? createRawType((ReferenceBinding)originalType.erasure(), null) : originalType;
} else {
ReferenceBinding convertedEnclosing;
- if (originalEnclosing.kind() == Binding.RAW_TYPE) {
- needToConvert |= !((ReferenceBinding)originalType).isStatic();
- convertedEnclosing = originalEnclosing;
- } else if (forceRawEnclosingType && !needToConvert/*stop recursion when conversion occurs*/) {
- convertedEnclosing = (ReferenceBinding) convertToRawType(originalEnclosing, forceRawEnclosingType);
- needToConvert = TypeBinding.notEquals(originalEnclosing, convertedEnclosing); // only convert generic or parameterized types
- } else if (needToConvert || ((ReferenceBinding)originalType).isStatic()) {
- convertedEnclosing = (ReferenceBinding) convertToRawType(originalEnclosing, false);
+ if(((ReferenceBinding)originalType).isStatic()) {
+ convertedEnclosing = (ReferenceBinding) originalEnclosing.original();
} else {
- convertedEnclosing = convertToParameterizedType(originalEnclosing);
+ if (originalEnclosing.kind() == Binding.RAW_TYPE) {
+ convertedEnclosing = originalEnclosing;
+ needToConvert = true;
+ } else if (forceRawEnclosingType && !needToConvert/*stop recursion when conversion occurs*/) {
+ convertedEnclosing = (ReferenceBinding) convertToRawType(originalEnclosing, forceRawEnclosingType);
+ needToConvert = TypeBinding.notEquals(originalEnclosing, convertedEnclosing); // only convert generic or parameterized types
+ } else if (needToConvert) {
+ convertedEnclosing = (ReferenceBinding) convertToRawType(originalEnclosing, false);
+ } else {
+ convertedEnclosing = convertToParameterizedType(originalEnclosing);
+ }
}
if (needToConvert) {
convertedType = createRawType((ReferenceBinding) originalType.erasure(), convertedEnclosing);
- } else if (TypeBinding.notEquals(originalEnclosing, convertedEnclosing) && !originalType.isStatic()) {
+ } else if (TypeBinding.notEquals(originalEnclosing, convertedEnclosing)) {
convertedType = createParameterizedType((ReferenceBinding) originalType.erasure(), null, convertedEnclosing);
} else {
convertedType = originalType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
index 5dcefd96d1..d3818a4829 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
@@ -57,7 +57,7 @@ public class RawTypeBinding extends ParameterizedTypeBinding {
}
}
}
- if (enclosingType == null || (enclosingType.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0) {
+ if (enclosingType == null || this.isStatic() || (enclosingType.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0) {
this.modifiers &= ~ExtraCompilerModifiers.AccGenericSignature; // only need signature if enclosing needs one
}
}
@@ -145,7 +145,7 @@ public class RawTypeBinding extends ParameterizedTypeBinding {
this.genericTypeSignature = genericType().signature();
} else {
StringBuffer sig = new StringBuffer(10);
- if (isMemberType()) {
+ if (isMemberType() && !isStatic()) {
ReferenceBinding enclosing = enclosingType();
char[] typeSig = enclosing.genericTypeSignature();
sig.append(typeSig, 0, typeSig.length-1);// copy all but trailing semicolon
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java
index cc5cff3fa5..cc07534a4b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java
@@ -355,6 +355,9 @@ public class TypeSystem {
this.types[unannotatedGenericType.id] = derivedTypes;
}
+ if(unannotatedGenericType.isStatic() && unannotatedEnclosingType != null) {
+ unannotatedEnclosingType=(ReferenceBinding) unannotatedEnclosingType.original();
+ }
TypeBinding rawTytpe = derivedTypes[i] = new RawTypeBinding(unannotatedGenericType, unannotatedEnclosingType, this.environment);
int typesLength = this.types.length;
if (this.typeid == typesLength)

Back to the top