mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: provide lambda incompatibility message based on failed inference (IDEA-131882)
This commit is contained in:
+7
-3
@@ -38,6 +38,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
@@ -314,10 +315,13 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
else {
|
||||
if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType) && !expression.hasFormalParameterTypes()) {
|
||||
String description = InferenceSession.getInferenceErrorMessage(PsiTreeUtil.getParentOfType(expression, PsiCallExpression.class));
|
||||
if (description == null) {
|
||||
description = "Cyclic inference";
|
||||
}
|
||||
HighlightInfo result =
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip("Cyclic inference")
|
||||
.create();
|
||||
myHolder.add(result); //todo[ann] append not inferred type params info
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create();
|
||||
myHolder.add(result);
|
||||
}
|
||||
else {
|
||||
final String incompatibleReturnTypesMessage = LambdaUtil
|
||||
|
||||
+3
-1
@@ -26,7 +26,9 @@ abstract class NoFormalParamTypeInferenceNeeded {
|
||||
{
|
||||
map(a -> zip(text -> text));
|
||||
zip(a -> zip(text -> text));
|
||||
Integer zip = zip(a -> zip(<error descr="Cyclic inference">text -> text</error>));
|
||||
Integer zip = zip(a -> zip(<error descr="inference variable R has incompatible bounds:
|
||||
lower bounds: Object
|
||||
upper bounds: Object, R">text -> text</error>));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user