-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax enforcement on conditional nullability attributes #46201
Conversation
Tagging @RikkiGibson for a second review. Thanks |
@@ -128481,6 +128447,42 @@ public new void M1<T>(System.Nullable<T?> x) | |||
); | |||
} | |||
|
|||
[Fact, WorkItem(43071, "https://github.com/dotnet/roslyn/issues/43071")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the implementation change affect behavior of this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No behavior change to this test, I'm just adding a test to close a different issue.
@@ -610,11 +605,6 @@ void enforceNotNullWhenForPendingReturn(PendingBranch pendingReturn, BoundExpres | |||
enforceParameterNotNullWhen(returnStatement.Syntax, parameters, sense: true, stateWhen: pendingReturn.StateWhenTrue); | |||
enforceParameterNotNullWhen(returnStatement.Syntax, parameters, sense: false, stateWhen: pendingReturn.StateWhenFalse); | |||
} | |||
else | |||
{ | |||
enforceParameterNotNullWhen(returnStatement.Syntax, parameters, sense: true, stateWhen: pendingReturn.State); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this works because we enter a split state after visiting a bool
constant, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline.
Fixes #44080
For example: in
void M([NotNullWhen(true)] out string? s) { s = null; return ...; }
we should complain in areturn true;
scenario, but not in areturn SomeBoolValue();
scenario.