mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
check type within its bound: raw types (IDEA-57288)
This commit is contained in:
+25
-2
@@ -69,7 +69,30 @@ public class WithingBounds {
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------
|
||||
void testE25() {
|
||||
class B {
|
||||
void foo() {
|
||||
this.<Iterable>bar();
|
||||
}
|
||||
|
||||
<T extends Iterable<String>> void bar() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testE26() {
|
||||
class A<T>{}
|
||||
class B {
|
||||
void foo() {
|
||||
this.<A>bar();
|
||||
}
|
||||
|
||||
<T extends A<String>> void bar() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
void testE3() {
|
||||
class A {
|
||||
@@ -143,4 +166,4 @@ public class WithingBounds {
|
||||
|
||||
ToCheckExtends<<error descr="Type parameter 'A' is not within its bound; should extend 'B'">? super A</error>> pr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,23 @@ public class TypesDistinctProver {
|
||||
if (type1 instanceof PsiClassType && ((PsiClassType)type1).resolve() instanceof PsiTypeParameter) return false;
|
||||
if (type2 instanceof PsiClassType && ((PsiClassType)type2).resolve() instanceof PsiTypeParameter) return false;
|
||||
|
||||
return !type1.equals(type2);
|
||||
if (TypeConversionUtil.erasure(type1).equals(TypeConversionUtil.erasure(type2))) {
|
||||
final PsiSubstitutor substitutor1 = PsiUtil.resolveGenericsClassInType(type1).getSubstitutor();
|
||||
final PsiSubstitutor substitutor2 = PsiUtil.resolveGenericsClassInType(type2).getSubstitutor();
|
||||
for (PsiTypeParameter parameter : substitutor1.getSubstitutionMap().keySet()) {
|
||||
final PsiType substitutedType1 = substitutor1.substitute(parameter);
|
||||
final PsiType substitutedType2 = substitutor2.substitute(parameter);
|
||||
if (substitutedType1 == null && substitutedType2 == null) return false;
|
||||
if (substitutedType1 == null || substitutedType2 == null) {
|
||||
for (PsiClassType type : parameter.getExtendsListTypes()) {
|
||||
if (!TypeConversionUtil.isAssignable(type, substitutedType1 != null ? substitutedType1 : substitutedType2, false)) return true;
|
||||
}
|
||||
} else if (provablyDistinct(substitutedType1, substitutedType2)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return type2 != null && type1 != null && !type1.equals(type2);
|
||||
}
|
||||
|
||||
public static boolean provablyDistinct(PsiWildcardType type1, PsiWildcardType type2) {
|
||||
|
||||
Reference in New Issue
Block a user