mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
false positive in redundant cast: applicable method with inference error (IDEA-186224)
This commit is contained in:
@@ -402,7 +402,8 @@ public class RedundantCastUtil {
|
||||
(!(newCall instanceof PsiCallExpression) ||
|
||||
oldAnonymousClass != null && newAnonymousClass != null && Comparing.equal(oldAnonymousClass.getBaseClassType(), newAnonymousClass.getBaseClassType()) ||
|
||||
Comparing.equal(PsiUtil.recaptureWildcards(((PsiCallExpression)newCall).getType(), expression), ((PsiCallExpression)expression).getType())) &&
|
||||
newResult.isValidResult()) {
|
||||
newResult.isValidResult() &&
|
||||
!(newResult instanceof MethodCandidateInfo && ((MethodCandidateInfo)newResult).getInferenceErrorMessage() != null)) {
|
||||
if (!(newArgs[i] instanceof PsiFunctionalExpression)) {
|
||||
addToResults(cast);
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
static class Node { }
|
||||
static class ValueNode extends Node {}
|
||||
|
||||
static void m(ValueNode v, Node n) {
|
||||
pathToCustomNode((Node)v, current -> n);
|
||||
}
|
||||
|
||||
public static <T> void pathToCustomNode(T node, Function<T, T> getParent) { }
|
||||
|
||||
}
|
||||
+1
@@ -82,6 +82,7 @@ public class LambdaRedundantCastTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testCastInConditionalBranch() { doTest();}
|
||||
public void testCastInsideLambdaReturnExpressionPassedToEnumConstant() { doTest(); }
|
||||
public void testGroundTargetTypeDiffersFromCastType() { doTest(); }
|
||||
public void testInferenceErrorForApplicableMethod() { doTest(); }
|
||||
public void testRejectReturnTypeChange() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user