mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
postpone highlighting on conditions when errors occur on containing call
poly conditional expression receives type from context, if context contains errors, it's better to highlight those first (IDEA-185540)
This commit is contained in:
@@ -1694,6 +1694,13 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitConditionalExpression(PsiConditionalExpression expression) {
|
||||
super.visitConditionalExpression(expression);
|
||||
if (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) && PsiPolyExpressionUtil.isPolyExpression(expression)) {
|
||||
PsiElement element = PsiUtil.skipParenthesizedExprUp(expression.getParent());
|
||||
if (element instanceof PsiExpressionList) {
|
||||
PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiCall && !((PsiCall)parent).resolveMethodGenerics().isValidResult()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final PsiExpression thenExpression = expression.getThenExpression();
|
||||
final PsiExpression elseExpression = expression.getElseExpression();
|
||||
if (thenExpression != null && elseExpression != null) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
|
||||
void test(int num) {
|
||||
m<error descr="'m(java.lang.String, int)' in 'Test' cannot be applied to '(java.lang.Integer)'">(num == 1 ? null : new Integer(1))</error>;
|
||||
}
|
||||
|
||||
void m(String s, int i) {}
|
||||
}
|
||||
@@ -181,6 +181,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
//public void _testAssignabilityOfStandaloneExpressionsDuringApplicabilityCheck() { doTest(); }
|
||||
public void testRecursiveTypeWithCapture() { doTest(); }
|
||||
public void testFreshVariablesDuringApplicabilityCheck() { doTest(); }
|
||||
public void testPostponeConditionalExpressionErrorToMethodLevel() { doTest(); }
|
||||
|
||||
public void testPertinentToApplicabilityCheckForBlockLambda() { doTest(); }
|
||||
public void testCheckGlbConflictsAfterIntersectionTypeCreated() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user