mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] isSafeLambdaReplacement: use copyWithExpectedType
GitOrigin-RevId: efdf10a2a346f4c33b18519377e2f6bb0306093d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
236350c86a
commit
28deec85d3
@@ -943,11 +943,7 @@ public final class LambdaUtil {
|
||||
else if (PsiPolyExpressionUtil.isInAssignmentOrInvocationContext(lambda)) {
|
||||
PsiType origType = lambda.getFunctionalInterfaceType();
|
||||
if (origType != null) {
|
||||
Project project = lambda.getProject();
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
|
||||
PsiDeclarationStatement declaration = factory.createVariableDeclarationStatement("$$$", origType, lambda, lambda);
|
||||
PsiLocalVariable variable = (PsiLocalVariable)declaration.getDeclaredElements()[0];
|
||||
PsiLambdaExpression lambdaCopy = (PsiLambdaExpression)variable.getInitializer();
|
||||
PsiLambdaExpression lambdaCopy = (PsiLambdaExpression)copyWithExpectedType(lambda, origType);
|
||||
PsiExpression replacement = replacer.apply(lambdaCopy);
|
||||
PsiType type = replacement.getType();
|
||||
return type != null && origType.isAssignableFrom(type);
|
||||
|
||||
Reference in New Issue
Block a user