conditional with eq branches: don't push conditional inside type cast for functional expressions, incorrect context will appear otherwise

This commit is contained in:
Anna Kozlova
2016-06-06 17:52:24 +03:00
parent 1fcb534fcb
commit f3363ce08c
2 changed files with 9 additions and 0 deletions
@@ -781,6 +781,9 @@ public class EquivalenceChecker {
}
final PsiExpression operand1 = typeCastExpression1.getOperand();
final PsiExpression operand2 = typeCastExpression2.getOperand();
if (operand1 instanceof PsiFunctionalExpression || operand2 instanceof PsiFunctionalExpression) {
return EXACTLY_UN_MATCHES;
}
return expressionsAreEquivalentDecision(operand1, operand2).setConcreteIfExactUnMatches(operand1, operand2);
}
@@ -72,4 +72,10 @@ class ConditionalExpressionWithIdenticalBranches {
String a = f ? test(new String[]{"a", "b"}) : test("a");
}
}
static class WithFunctionalExpression {
private void foo(boolean b) {
Runnable r = b ? (Runnable) () -> {} : (Runnable) () -> {};
}
}
}