new inference: missed condition in conditional expression (IDEA-127752)

This commit is contained in:
Anna Kozlova
2014-07-23 18:37:22 +02:00
parent c88f288bda
commit 24be503eb2
3 changed files with 23 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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";
}
}

View File

@@ -188,6 +188,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testInferFromConditionalExpressionCondition() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}