@NotNull
  private static Nullability getElementNullability(@Nullable PsiType resultType,
                                                   @Nullable PsiModifierListOwner owner,
                                                   boolean ignoreParameterNullabilityInference) {
    if (owner == null) return getTypeNullability(resultType);

    if (resultType instanceof PsiPrimitiveType) {
      return Nullability.UNKNOWN;
    }

    if (owner instanceof PsiEnumConstant) {
      return Nullability.NOT_NULL;
    }

    // Annotation manager requires index
    if (DumbService.isDumb(owner.getProject())) return Nullability.UNKNOWN;
    NullabilityAnnotationInfo fromAnnotation = getNullabilityFromAnnotation(owner, ignoreParameterNullabilityInference);
    if (fromAnnotation != null) {
      if (fromAnnotation.getNullability() == Nullability.NULLABLE &&
          owner instanceof PsiMethod method) {
        PsiType type = method.getReturnType();
        PsiAnnotationOwner annotationOwner = fromAnnotation.getAnnotation().getOwner();
        if (PsiUtil.resolveClassInClassTypeOnly(type) instanceof PsiTypeParameter &&
            annotationOwner instanceof PsiType && annotationOwner != type) {
          // Nullable from type hierarchy: should check the instantiation, as it could be more concrete
          Nullability fromType = getNullabilityFromType(resultType, owner);
          if (fromType != null) return fromType;
        }
      }
      return fromAnnotation.getNullability();
    }

    if (owner instanceof PsiMethod method) {
      if (isEnumPredefinedMethod(method)) {
        return Nullability.NOT_NULL;
      }
      if (isMapMethodWithUnknownNullity(method)) {
        return getTypeNullability(resultType) == Nullability.NULLABLE ? Nullability.NULLABLE : Nullability.UNKNOWN;
      }
    }

    if (owner instanceof PsiParameter parameter) {
      Nullability nullability = inferParameterNullability(parameter);
      if (nullability != Nullability.UNKNOWN) {
        return nullability;
      }
    }

    Nullability fromType = getNullabilityFromType(resultType, owner);
    if (fromType != null) return fromType;

    if (owner instanceof PsiMethod method && method.getParameterList().isEmpty()) {
      PsiField field = PropertyUtil.getFieldOfGetter(method);
      if (field != null && getElementNullability(resultType, field) == Nullability.NULLABLE) {
        return Nullability.NULLABLE;
      }
    }

    return Nullability.UNKNOWN;
  }
@NotNull
  private static Nullability getElementNullability(@Nullable PsiType resultType,
                                                   @Nullable PsiModifierListOwner owner,
                                                   boolean ignoreParameterNullabilityInference)