mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
don't highlight part of poly conditional expression when it's type is not defined, would be highlighted on top level (IDEA-171431)
This commit is contained in:
+4
@@ -50,6 +50,7 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
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.PsiLiteralExpressionImpl;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
@@ -2540,6 +2541,9 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
PsiType thenType = thenExpression.getType();
|
||||
if (thenType == null || type == null) return null;
|
||||
if (conditionalExpression.getType() == null) {
|
||||
if (PsiUtil.isLanguageLevel8OrHigher(conditionalExpression) && PsiPolyExpressionUtil.isPolyExpression(conditionalExpression)) {
|
||||
return null;
|
||||
}
|
||||
// cannot derive type of conditional expression
|
||||
// elseType will never be cast-able to thenType, so no quick fix here
|
||||
return createIncompatibleTypeHighlightInfo(thenType, type, expression.getTextRange(), 0);
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
class Test{
|
||||
void test() {
|
||||
B b = new B<error descr="'B(java.lang.String, java.lang.String)' in 'Test.B' cannot be applied to '(?)'">(true == false ? "bar" : null)</error>;
|
||||
}
|
||||
|
||||
class B {
|
||||
B(String c, String d ) {}
|
||||
}
|
||||
}
|
||||
+4
@@ -1024,4 +1024,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testSameErasureForStaticMethodsInInterfaces() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConditionalExpressionInIncompleteCall() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user