diff --git a/MaybeError/Maybe.cs b/MaybeError/Maybe.cs index b3d9064..cd434c2 100644 --- a/MaybeError/Maybe.cs +++ b/MaybeError/Maybe.cs @@ -49,10 +49,11 @@ public interface IMaybe where E : Error public readonly struct MaybeEx : IMaybe> where Ex : Exception { [MemberNotNullWhen(true, nameof(Error))] + [MemberNotNullWhen(false, nameof(_value))] public readonly bool HasError { get; } public readonly bool HasValue => !HasError; public readonly ExceptionError? Error { get; init; } - public readonly T Value => HasError ? throw Error.GetException() : _value!; + public readonly T Value => HasError ? throw Error.GetException() : _value; private readonly T? _value; /// @@ -113,10 +114,11 @@ public readonly struct MaybeEx : IMaybe> where Ex : public readonly struct Maybe : IMaybe where E: Error { [MemberNotNullWhen(true, nameof(Error))] + [MemberNotNullWhen(false, nameof(_value))] public readonly bool HasError { get; } public readonly bool HasValue => !HasError; public readonly E? Error { get; init; } - public readonly T Value => HasError ? throw Error.GetException() : _value!; + public readonly T Value => HasError ? throw Error.GetException() : _value; private readonly T? _value; @@ -174,10 +176,11 @@ public readonly struct Maybe : IMaybe where E: Error public readonly struct Maybe : IMaybe { [MemberNotNullWhen(true, nameof(Error))] + [MemberNotNullWhen(false, nameof(_value))] public readonly bool HasError { get; } public readonly bool HasValue => !HasError; public readonly Error? Error { get; } - public readonly T Value => HasError ? throw Error.GetException() : _value!; + public readonly T Value => HasError ? throw Error.GetException() : _value; private readonly T? _value;