redundant cast: test inference errors when applicability is checked (IDEA-151091)

This commit is contained in:
Anna Kozlova
2016-02-01 20:06:49 +03:00
parent 896288967d
commit 074aaaef53
4 changed files with 22 additions and 2 deletions
@@ -370,8 +370,9 @@ public class RedundantCastUtil {
}
} else {
final JavaResolveResult newResult = newCall.resolveMethodGenerics();
if (oldMethod.equals(newResult.getElement()) && newResult.isValidResult() &&
Comparing.equal(((PsiCallExpression)newCall).getType(), ((PsiCallExpression)expression).getType())) {
if (oldMethod.equals(newResult.getElement()) &&
Comparing.equal(((PsiCallExpression)newCall).getType(), ((PsiCallExpression)expression).getType()) &&
newResult.isValidResult()) {
final PsiMethod newFunctionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(newArgs[i]);
if (oldFunctionalInterfaceMethod == null ||
newFunctionalInterfaceMethod != null && (newFunctionalInterfaceMethod == oldFunctionalInterfaceMethod ||
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,16 @@
class RedundantCast {
ParentStrategy strategy;
public void cast() {
use((ChildStrategy) strategy);
}
private <T> void use(ChildStrategy<T> strategy) {
}
}
interface ParentStrategy<T> {
}
interface ChildStrategy<T> extends ParentStrategy<T> {
}
@@ -34,6 +34,7 @@ public class RedundantCast18Test extends InspectionTestCase {
public void testExpectedSupertype() throws Exception { doTest(); }
public void testForeachValue() throws Exception { doTest(); }
public void testConditional() throws Exception { doTest(); }
public void testInferApplicabilityError() throws Exception { doTest(); }
@Override
protected Sdk getTestProjectSdk() {