-
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
Check NotNullIfNotNull in implementation #47649
Conversation
This introduces multiple new warnings to the bootstrap build. I think the warnings are.. fair? Interesting.
roslyn/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs Lines 174 to 184 in 3a976eb
roslyn/src/Compilers/CSharp/Portable/Syntax/CSharpSyntaxRewriter.cs Lines 35 to 52 in 3a976eb
|
The local rewriter warning should be fixed by annotating |
I think this might not be right, because VisitExpressionImpl's parameter has a non-null type, and adding the attribute introduces a different warning:
I think something about the Debug.Assert is giving the |
I have opened a tracking issue #47682 and have suppressed the new warnings, since "proper" fixes for the warnings seem non-trivial. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@dotnet/roslyn-compiler Please review |
continue; | ||
} | ||
|
||
var annotations = parameter.FlowAnalysisAnnotations; |
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.
Why didn't u use GetFlowAnalysisAnnotations
here?
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.
This code was moved from parameterHasBadState
below. However GetFlowAnalysisAnnotations(Symbol)
here would just dispatch out to ParameterSymbol.FlowAnalysisAnnotations
.
It could make sense to change this to GetParameterAnnotations
in order to avoid attribute binding cycles. Since I can't come up with a crashing scenario for this off the top of my head I would like to punt changes to it to #47635
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
Show resolved
Hide resolved
{ | ||
x = null; | ||
return; // 4 | ||
} |
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.
Please add a few cases for constructors where the only code in the method is a :this
call to another constructor and verify that we validate not-null correctly in those cases.
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.
I wasn't sure exactly what this meant--do you want tests where constructor parameters have [NotNull]
and [NotNullIfNotNull]
?
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
Show resolved
Hide resolved
Changing base so we can get this change into 16.8. |
Closes #44539
VS validation: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/274873