mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
type parameter in bounds check: separate wildcards with type param in bound
This commit is contained in:
+3
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -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>) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user