mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant cast: test inference errors when applicability is checked (IDEA-151091)
This commit is contained in:
@@ -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 ||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
+16
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user