mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEADEV-41413 [anna]
This commit is contained in:
+29
-2
@@ -1178,8 +1178,7 @@ public class GenericsHighlightUtil {
|
||||
if (parameterList != null && parameterList.getTypeArguments().length > 0) {
|
||||
final String message = JavaErrorMessages.message("generics.select.static.class.from.parameterized.type",
|
||||
HighlightUtil.formatClass((PsiClass)resolved));
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
parameterList, message);
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, parameterList, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1193,5 +1192,33 @@ public class GenericsHighlightUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static HighlightInfo checkTopLevelMethodCallIntersectionTypeMaximalUpperBound(PsiMethodCallExpression methodCall,
|
||||
PsiReferenceExpression expression) {
|
||||
PsiElement parent = methodCall.getParent();
|
||||
if (parent instanceof PsiExpression) return null;
|
||||
PsiType type = expression.getType();
|
||||
if (!(type instanceof PsiIntersectionType)) {
|
||||
return null;
|
||||
}
|
||||
PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
|
||||
PsiType lub = conjuncts[0];
|
||||
for (int i = 1; i < conjuncts.length; i++) {
|
||||
PsiType conjunct = conjuncts[i];
|
||||
PsiType bound = GenericsUtil.getLeastUpperBound(lub, conjunct, methodCall.getManager());
|
||||
if (bound == null || !TypeConversionUtil.isAssignable(lub, bound) || !TypeConversionUtil.isAssignable(conjunct, bound)) {
|
||||
PsiMethod method = methodCall.resolveMethod();
|
||||
if (method == null) return null;
|
||||
String message = JavaErrorMessages.message("failed.to.find.unique.maximal.instance",
|
||||
HighlightUtil.formatMethod(method),
|
||||
HighlightUtil.formatType(lub), HighlightUtil.formatType(conjunct));
|
||||
|
||||
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, message);
|
||||
}
|
||||
lub = bound;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -768,8 +768,11 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
else {
|
||||
PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression && ((PsiMethodCallExpression)parent).getMethodExpression() == expression) {
|
||||
myHolder.addAll(HighlightMethodUtil.checkMethodCall((PsiMethodCallExpression)parent, myResolveHelper));
|
||||
PsiMethodCallExpression methodCall;
|
||||
|
||||
if (parent instanceof PsiMethodCallExpression && (methodCall = (PsiMethodCallExpression)parent).getMethodExpression() == expression) {
|
||||
myHolder.addAll(HighlightMethodUtil.checkMethodCall(methodCall, myResolveHelper));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkTopLevelMethodCallIntersectionTypeMaximalUpperBound(methodCall, expression));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -335,3 +335,4 @@ illegal.initializer=Illegal initializer for ''{0}''
|
||||
class.cannot.inherit.from.its.type.parameter=Class cannot inherit from its type parameter
|
||||
cannot.resolve.package=Cannot resolve package {0}
|
||||
override.not.allowed.in.interfaces=@Override is not allowed when implementing interface method
|
||||
failed.to.find.unique.maximal.instance=Cannot determine type parameters for ''{0}'': no unique maximal instance of upper bounds ''{1}'' and ''{2}''
|
||||
|
||||
Reference in New Issue
Block a user