void (int i, PsiTypeCastExpression returnExpression, PsiTypeCastExpression newReturnExpression, PsiType originalFunctionalInterfaceType, PsiLambdaExpression newLambdaExpression, PsiCall oldCall, PsiCall newCall, PsiParameter[] parameters) { PsiExpression castOperand = getInnerMostOperand(returnExpression); if (castOperand == null) return; final PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(originalFunctionalInterfaceType); if (interfaceReturnType == null || !isFunctionalExpressionTypePreserved(returnExpression, castOperand, interfaceReturnType)) return; PsiExpression strippedCast = (PsiExpression)newReturnExpression.replace(castOperand); PsiType newArgType = calculateNewArgType(i, resolveNewResult(oldCall, newCall), parameters); final PsiType functionalInterfaceType = newLambdaExpression.getGroundTargetType(newArgType); if (originalFunctionalInterfaceType.equals(functionalInterfaceType)) { final PsiType castExprType = LambdaUtil.performWithTargetType(newLambdaExpression, functionalInterfaceType, () -> strippedCast.getType()); if (castExprType != null && interfaceReturnType.isAssignableFrom(castExprType)) { addToResults(returnExpression); return; } } strippedCast.replace(returnExpression); }