Nullability (@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; } NullabilityAnnotationInfo fromAnnotation = getNullabilityFromAnnotation(owner, ignoreParameterNullabilityInference); if (fromAnnotation != null) { 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 = getTypeNullability(resultType); if (fromType != Nullability.UNKNOWN) { if (fromType == Nullability.NOT_NULL && hasNullContract(owner)) { return Nullability.UNKNOWN; } 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; }