boolean (@NotNull PsiParameterList parameterList) { final PsiElement parent = parameterList.getParent(); if (!(parent instanceof PsiLambdaExpression expression)) return false; final PsiParameter[] parameters = parameterList.getParameters(); for (PsiParameter parameter : parameters) { PsiTypeElement typeElement = parameter.getTypeElement(); if (typeElement == null) return false; if (!PsiUtil.isLanguageLevel11OrHigher(parameterList)) { if (AnonymousCanBeLambdaInspection.mustKeepAnnotations(parameter, Collections.emptySet())) { return false; } } else if (typeElement.isInferredType() && keepVarType(parameter)) return false; } if (parameters.length == 0) return false; final PsiType functionalInterfaceType = expression.getFunctionalInterfaceType(); if (functionalInterfaceType == null) return false; return LambdaUtil.isSafeLambdaReplacement(expression, () -> { PsiLambdaExpression lambdaWithoutParameters = (PsiLambdaExpression)expression.copy(); for (PsiParameter parameter : lambdaWithoutParameters.getParameterList().getParameters()) { PsiTypeElement typeElement = Objects.requireNonNull(parameter.getTypeElement()); typeElement.delete(); } return lambdaWithoutParameters; }); }