type parameter in bounds check: separate wildcards with type param in bound

This commit is contained in:
anna
2013-10-10 18:39:55 +02:00
parent efc19abeff
commit 6a9313c58e
3 changed files with 24 additions and 3 deletions
@@ -276,7 +276,9 @@ public class GenericsHighlightUtil {
return checkExtendsWildcardCaptureFailure((PsiWildcardType)type, bound);
}
else if (((PsiWildcardType)type).isSuper()) {
return checkNotAssignable(bound, ((PsiWildcardType)type).getSuperBound(), false);
final PsiType superBound = ((PsiWildcardType)type).getSuperBound();
if (PsiUtil.resolveClassInType(superBound) instanceof PsiTypeParameter) return TypesDistinctProver.provablyDistinct(type, bound);
return checkNotAssignable(bound, superBound, false);
}
}
else if (type instanceof PsiArrayType) {
@@ -72,7 +72,16 @@ public class TypesDistinctProver {
proveArrayTypeDistinct(((PsiWildcardType)type1).getManager().getProject(), (PsiArrayType)superBound, type2)) return true;
final PsiClass boundClass1 = PsiUtil.resolveClassInType(superBound);
if (boundClass1 == null || boundClass1 instanceof PsiTypeParameter) return false;
if (boundClass1 == null) return false;
if (boundClass1 instanceof PsiTypeParameter) {
final PsiClassType[] extendsListTypes = boundClass1.getExtendsListTypes();
for (PsiClassType classType : extendsListTypes) {
final PsiClass psiClass = classType.resolve();
if (InheritanceUtil.isInheritorOrSelf(psiClass, psiClass2, true) || InheritanceUtil.isInheritorOrSelf(psiClass2, psiClass, true)) return false;
}
return extendsListTypes.length > 0;
}
return !InheritanceUtil.isInheritorOrSelf(boundClass1, psiClass2, true);
}
@@ -243,4 +243,14 @@ class IDEA89640 {
boolean flag = a != b;
System.out.println(flag);
}
}
}
interface Parametrized<<warning descr="Type parameter 'T' is never used">T</warning> extends Number> {
class Bug1<T extends java.io.Serializable> {
void bug1(Parametrized<? super T> <warning descr="Parameter 'param' is never used">param</warning>) {}
}
class Bug2<T extends String> {
void bug1(Parametrized<<error descr="Type parameter '? super T' is not within its bound; should extend 'java.lang.Number'">? super T</error>> <warning descr="Parameter 'param' is never used">param</warning>) {}
}
}