boolean (int argCount, @Nullable PsiExpression functionalExpression, Nullability resultNullability, Runnable pushArgs) { PsiExpression stripped = PsiUtil.deparenthesizeExpression(functionalExpression); if (stripped instanceof PsiLambdaExpression lambda) { PsiParameter[] parameters = lambda.getParameterList().getParameters(); if (parameters.length == argCount && lambda.getBody() != null) { pushArgs.run(); StreamEx.ofReversed(parameters).forEach(p -> assignTo(p).pop()); inlineLambda(lambda, resultNullability); StreamEx.of(parameters).forEach(p -> add(new FlushVariableInstruction( PlainDescriptor.createVariableValue(getFactory(), p)))); return true; } } PsiLocalVariable localFn = ExpressionUtils.resolveLocalVariable(stripped); if (localFn != null) { PsiElement parent = PsiTreeUtil.getParentOfType(functionalExpression, PsiLambdaExpression.class, PsiClass.class, PsiMethod.class); if (PsiTreeUtil.isAncestor(parent, localFn, true)) { PsiLambdaExpression localLambda = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprDown(localFn.getInitializer()), PsiLambdaExpression.class); if (myAnalyzer.wasAdded(localLambda)) { PsiElement scope = PsiUtil.getVariableCodeBlock(localFn, null); List<PsiReferenceExpression> refs = VariableAccessUtils.getVariableReferences(localFn, scope); if (ContainerUtil.getOnlyItem(refs) == stripped) { myAnalyzer.removeLambda(localLambda); return tryInlineLambda(argCount, localLambda, resultNullability, pushArgs); } } } } return false; }