process intersection types correctly

This commit is contained in:
anna
2012-05-03 09:19:04 +02:00
parent b631a56f9d
commit 2cf7167ae7
@@ -889,10 +889,10 @@ public class TypeConversionUtil {
}
else {
if (leftWildcard.isExtends()) {
return isAssignable(leftBound, typeRight, allowUncheckedConversion && !leftBound.accept(new WildcardDetector()));
return isAssignable(leftBound, typeRight, allowUncheckedConversion && !containsWildcards(leftBound));
}
else { // isSuper
return isAssignable(typeRight, leftBound, allowUncheckedConversion && !leftBound.accept(new WildcardDetector()));
return isAssignable(typeRight, leftBound, allowUncheckedConversion && !containsWildcards(leftBound));
}
}
}
@@ -901,6 +901,18 @@ public class TypeConversionUtil {
}
}
private static Boolean containsWildcards(PsiType leftBound) {
final WildcardDetector wildcardDetector = new WildcardDetector();
if (leftBound instanceof PsiIntersectionType) {
for (PsiType conjunctType :((PsiIntersectionType)leftBound).getConjuncts()) {
if (!conjunctType.accept(wildcardDetector)) return false;
}
return true;
}
return leftBound.accept(wildcardDetector);
}
@Nullable
public static PsiSubstitutor getClassSubstitutor(@NotNull PsiClass superClassCandidate,
@NotNull PsiClass derivedClassCandidate,
@@ -1712,6 +1724,7 @@ public class TypeConversionUtil {
@Override
public Boolean visitType(PsiType type) {
//todo intersection types
return false;
}
}