mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reject functional expressions as conditional condition (IDEA-184667)
This commit is contained in:
@@ -337,9 +337,9 @@ public class LambdaUtil {
|
||||
PsiElement parent = expression.getParent();
|
||||
PsiElement element = expression;
|
||||
while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiConditionalExpression) {
|
||||
if (parent instanceof PsiConditionalExpression &&
|
||||
((PsiConditionalExpression)parent).getThenExpression() != element &&
|
||||
((PsiConditionalExpression)parent).getElseExpression() != element) break;
|
||||
if (parent instanceof PsiConditionalExpression && ((PsiConditionalExpression)parent).getCondition() == element) {
|
||||
return PsiType.BOOLEAN;
|
||||
}
|
||||
element = parent;
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
{
|
||||
boolean condition = <error descr="boolean is not a functional interface">() -> {}</error> ? true : false;
|
||||
}
|
||||
}
|
||||
+1
@@ -163,6 +163,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA174924() { doTest(); }
|
||||
public void testVoidValueCompatibilityWithBreakInSwitch() { doTest(); }
|
||||
public void testExceptionInferenceForVarargMethods() { doTest(); }
|
||||
public void testConditionalBooleanAsFunctionalInterfaceType() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
|
||||
Reference in New Issue
Block a user