@NotNull
  private InferenceStep handleConversionOfSAMType(@Nullable PsiType targetType,
                                                  @NotNull PsiType closure,
                                                  PsiTypeParameter[] typeParameters) {
    if (!(closure instanceof PsiClassType)) return InferenceStep.EMPTY;
    if (!(targetType instanceof PsiClassType)) return InferenceStep.EMPTY;

    ClassResolveResult resolveResult = ((PsiClassType)targetType).resolveGenerics();

    PsiClass samClass = resolveResult.getElement();
    if (samClass == null) return InferenceStep.EMPTY;

    PsiMethod sam = findSingleAbstractMethod(samClass);
    if (sam == null) return InferenceStep.EMPTY;

    PsiType samReturnType = resolveResult.getSubstitutor().substitute(sam.getReturnType());
    if (samReturnType == null) return InferenceStep.EMPTY;

    return buildReturnTypeClosureStep(closure, samReturnType, typeParameters);
  }
@NotNull
  private InferenceStep handleConversionOfSAMType(@Nullable PsiType targetType,
                                                  @NotNull PsiType closure,
                                                  PsiTypeParameter[] typeParameters)