mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[java-intentions] IDEA-368928 Unnecessary cast fix for lambdas
GitOrigin-RevId: dec2f6e7bedca3686532264db331371119146527
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c9553dc4d1
commit
1b0fcea7e2
+3
-1
@@ -8,6 +8,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -67,7 +68,8 @@ public abstract class ArgumentFixerActionFactory {
|
||||
Map<Integer, PsiType> potentialCasts = new HashMap<>();
|
||||
for (int i = 0; i < expressions.length; i++) {
|
||||
PsiExpression expression = expressions[i];
|
||||
PsiType exprType = expression.getType();
|
||||
PsiType exprType = PsiUtil.skipParenthesizedExprDown(expression) instanceof PsiFunctionalExpression fn ?
|
||||
fn.getFunctionalInterfaceType() : expression.getType();
|
||||
PsiType originalParameterType = PsiTypesUtil.getParameterType(parameters, i, true);
|
||||
PsiType parameterType = substitutor.substitute(originalParameterType);
|
||||
if (!PsiTypesUtil.isDenotableType(parameterType, call)) continue;
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Cast 1st argument to 'Consumer<String>'" "false"
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class Test {
|
||||
void foo(Consumer<String> cons, String a) {
|
||||
}
|
||||
|
||||
void foo(Consumer<String> cons, Character a) {
|
||||
}
|
||||
|
||||
void test() {
|
||||
foo(s -><caret>
|
||||
System.out.println(s.length()), 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user