mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-126120 Proper handling for intersection types
This commit is contained in:
+15
-4
@@ -221,20 +221,31 @@ public class TypesUtil {
|
||||
@NotNull PsiElement context,
|
||||
@NotNull ApplicableTo position) {
|
||||
if (actualType instanceof PsiIntersectionType) {
|
||||
ConversionResult min = ConversionResult.ERROR;
|
||||
for (PsiType child : ((PsiIntersectionType)actualType).getConjuncts()) {
|
||||
if (canAssign(targetType, child, context, position) == ConversionResult.OK) {
|
||||
final ConversionResult result = canAssign(targetType, child, context, position);
|
||||
if (result.ordinal() < min.ordinal()) {
|
||||
min = result;
|
||||
}
|
||||
if (min == ConversionResult.OK) {
|
||||
return ConversionResult.OK;
|
||||
}
|
||||
}
|
||||
return ConversionResult.ERROR;
|
||||
return min;
|
||||
}
|
||||
|
||||
if (targetType instanceof PsiIntersectionType) {
|
||||
ConversionResult max = ConversionResult.OK;
|
||||
for (PsiType child : ((PsiIntersectionType)targetType).getConjuncts()) {
|
||||
if (canAssign(child, actualType, context, position) != ConversionResult.OK) {
|
||||
final ConversionResult result = canAssign(child, actualType, context, position);
|
||||
if (result.ordinal() > max.ordinal()) {
|
||||
max = result;
|
||||
}
|
||||
if (max == ConversionResult.ERROR) {
|
||||
return ConversionResult.ERROR;
|
||||
}
|
||||
}
|
||||
return ConversionResult.OK;
|
||||
return max;
|
||||
}
|
||||
|
||||
final ConversionResult result = areTypesConvertible(targetType, actualType, context, position);
|
||||
|
||||
Reference in New Issue
Block a user