-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Improve nullable analysis of local functions #40422
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
Conversation
d5bff1a to
a5054ef
Compare
This design tries to meld better analysis of nullable reference types in local functions with performance. To keep the common case one pass, local functions are analyzed using the starting state that is an intersection of all the states before its usages (calls, delegate conversions, etc), but the results of variables made nullable or non-nullable inside the local function do not propagate to the callers.
a5054ef to
58db000
Compare
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs
Outdated
Show resolved
Hide resolved
|
Could you add the test shown in #40157? How does it interact with this change? |
|
Done review pass (commit 1) |
I didn't try to address that. I can see two possible specs for the behavior in the absence of a call: we could treat captured variables as always being non-null, or we use the annotation. My preference would be on the first, but I don't think we've made a decision either way. |
|
I'll take a look shortly. |
jcouv
left a comment
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.
LGTM Thanks (iteration 2)
|
@agocke Anything holding us back from merging this? |
|
Merged to unblock my other PR. Andy said it's ready to merge |
|
SGTM thanks |
* dotnet/master: (592 commits) Improve nullable analysis of local functions (dotnet#40422) Fix race condition in CodeFixService Annotate CSharpCompilation (dotnet#40752) Revert "Merge pull request dotnet#40765 from dibarbet/revert_use_index" More feedback address feedback More refactoring and hardening of remote calls (dotnet#40395) Update PublishData.json Unskip and fix integration test Update configs for preview 2 snap Improve error message for CS0191 (dotnet#40748) Revert "Merge pull request dotnet#40410 from sharwell/use-index" PR feedback Report erroneous implicit conversions in a switch expression (dotnet#40678) Ignore dynamic vs object, etc in pattern-matching machinery. (dotnet#40677) Handle dependent slots in pattern-matching null tests. (dotnet#39625) Pass non-null arguments to avoid nullability warning Update dependencies from https://github.com/dotnet/arcade build 20200104.1 (dotnet#40749) [master] Update dependencies from dotnet/arcade (dotnet#40718) Expose display option to add ! on non-nullable types (dotnet#40519) ...
This design tries to meld better analysis of nullable reference types in
local functions with performance. To keep the common case one pass,
local functions are analyzed using the starting state that is an
intersection of all the states before its usages (calls, delegate
conversions, etc), but the results of variables made nullable or
non-nullable inside the local function do not propagate to the callers.