private static PsiType getEnclosingReturnType(PsiElement element) {
    PsiElement enclosing = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiLambdaExpression.class);
    if (enclosing instanceof PsiMethod enclMethod) return enclMethod.getReturnType();
    if (enclosing instanceof PsiLambdaExpression enclLambda) return LambdaUtil.getFunctionalInterfaceReturnType(enclLambda);
    return null;
  }
private static PsiType getEnclosingReturnType(PsiElement element)