nested conditional expressions: don't require nested to be poly if outer is not

This commit is contained in:
Anna Kozlova
2015-05-13 11:13:22 +02:00
parent 6e46f6ff0a
commit fb0495e4a4
3 changed files with 13 additions and 1 deletions

View File

@@ -128,7 +128,7 @@ public class PsiPolyExpressionUtil {
final PsiElement context = PsiUtil.skipParenthesizedExprUp(expr.getParent());
return context instanceof PsiExpressionList ||
context instanceof PsiArrayInitializerExpression ||
context instanceof PsiConditionalExpression ||
context instanceof PsiConditionalExpression && isPolyExpression((PsiExpression)context) ||
isAssignmentContext(expr, context);
}

View File

@@ -0,0 +1,8 @@
import java.util.ArrayList;
import java.util.List;
class C {
public static void main(Object o) {
List l = (List)(o instanceof ArrayList ? (ArrayList)o : o instanceof List ? (List)o : o);
}
}

View File

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