mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 22:11:40 +07:00
new inference: missed condition in conditional expression (IDEA-127752)
This commit is contained in:
@@ -1099,6 +1099,11 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiConditionalExpression) {
|
||||
if (checkSameExpression(expr, ((PsiConditionalExpression)parent).getCondition())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
static class TKey<T> {
|
||||
}
|
||||
|
||||
public interface Getter {
|
||||
<T> T getValue(TKey<T> key);
|
||||
}
|
||||
|
||||
static final TKey<Boolean> KEY_B = new TKey<>();
|
||||
|
||||
public static void f(Getter getter) {
|
||||
String name = getter.getValue(KEY_B) ? "foo" : "bar";
|
||||
}
|
||||
}
|
||||
@@ -188,6 +188,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInferFromConditionalExpressionCondition() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user