mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
class types are not provably distinct when they belong to one hierarchy
This commit is contained in:
@@ -509,3 +509,24 @@ class Refx<T> {
|
||||
return (Class<Enum>)get() == Enum.class;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//hierarchy of type param bound
|
||||
abstract class DomInvocationHandler<T extends AbstractDomChildDescriptionImpl> {
|
||||
void f() {
|
||||
if (this instanceof IndexedElementInvocationHandler) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface AbstractDomChildrenDescription {
|
||||
}
|
||||
|
||||
class AbstractDomChildDescriptionImpl implements AbstractDomChildrenDescription {
|
||||
}
|
||||
|
||||
class IndexedElementInvocationHandler extends DomInvocationHandler<FixedChildDescriptionImpl> {
|
||||
}
|
||||
|
||||
class FixedChildDescriptionImpl extends AbstractDomChildDescriptionImpl {
|
||||
}
|
||||
@@ -79,9 +79,11 @@ public class TypesDistinctProver {
|
||||
if (type2 instanceof PsiWildcardType || type2 instanceof PsiCapturedWildcardType) return provablyDistinct(type2, type1);
|
||||
|
||||
|
||||
final PsiClassType.ClassResolveResult classResolveResult1 = PsiUtil.resolveGenericsClassInType(type1);
|
||||
final PsiClassType.ClassResolveResult classResolveResult2 = PsiUtil.resolveGenericsClassInType(type2);
|
||||
if (Comparing.equal(TypeConversionUtil.erasure(type1), TypeConversionUtil.erasure(type2))) {
|
||||
final PsiSubstitutor substitutor1 = PsiUtil.resolveGenericsClassInType(type1).getSubstitutor();
|
||||
final PsiSubstitutor substitutor2 = PsiUtil.resolveGenericsClassInType(type2).getSubstitutor();
|
||||
final PsiSubstitutor substitutor1 = classResolveResult1.getSubstitutor();
|
||||
final PsiSubstitutor substitutor2 = classResolveResult2.getSubstitutor();
|
||||
for (PsiTypeParameter parameter : substitutor1.getSubstitutionMap().keySet()) {
|
||||
final PsiType substitutedType1 = substitutor1.substitute(parameter);
|
||||
final PsiType substitutedType2 = substitutor2.substitute(parameter);
|
||||
@@ -95,7 +97,11 @@ public class TypesDistinctProver {
|
||||
return false;
|
||||
}
|
||||
|
||||
return type2 != null && type1 != null && !type1.equals(type2);
|
||||
final PsiClass boundClass1 = classResolveResult1.getElement();
|
||||
final PsiClass boundClass2 = classResolveResult2.getElement();
|
||||
return type2 != null && type1 != null && !type1.equals(type2) &&
|
||||
!InheritanceUtil.isInheritorOrSelf(boundClass1, boundClass2, true) &&
|
||||
!InheritanceUtil.isInheritorOrSelf(boundClass2, boundClass1, true);
|
||||
}
|
||||
|
||||
public static boolean provablyDistinct(PsiWildcardType type1, PsiWildcardType type2) {
|
||||
|
||||
Reference in New Issue
Block a user