void (@NotNull HighlightInfo.Builder info, @NotNull TextRange textRange, @NotNull PsiLambdaExpression arg, @NotNull PsiClassType parameterType, @Nullable PsiType expectedArgType, @NotNull PsiTypeParameter typeParameter) { if (!(expectedArgType instanceof PsiClassType)) return; PsiExpression lambdaBody = LambdaUtil.extractSingleExpressionFromBody(arg.getBody()); if (lambdaBody == null) return; PsiClass fnInterface = parameterType.resolve(); if (fnInterface == null) return; PsiType[] fnArgs = parameterType.getParameters(); PsiTypeParameter[] fnParams = fnInterface.getTypeParameters(); if (fnArgs.length != fnParams.length) return; PsiType fnTypeArgumentToChange = StreamEx.of(fnArgs) .collect(MoreCollectors.onlyOne(c -> PsiTypesUtil.mentionsTypeParameters(c, Set.of(typeParameter)))).orElse(null); if (fnTypeArgumentToChange == null) return; int index = ArrayUtil.indexOf(fnArgs, fnTypeArgumentToChange); if (index == -1) return; PsiTypeParameter fnParam = fnParams[index]; PsiMethod sam = LambdaUtil.getFunctionalInterfaceMethod(fnInterface); if (sam == null) return; Set<PsiTypeParameter> fnParamSet = Set.of(fnParam); PsiType returnType = sam.getReturnType(); if (!PsiTypesUtil.mentionsTypeParameters(returnType, fnParamSet) || ContainerUtil.exists(sam.getParameterList().getParameters(), p -> PsiTypesUtil.mentionsTypeParameters(p.getType(), fnParamSet))) { return; } PsiType expectedFnReturnType = LambdaUtil.getFunctionalInterfaceReturnType(expectedArgType); if (expectedFnReturnType == null) return; registerExpectedTypeFixes(info, textRange, lambdaBody, expectedFnReturnType); }