-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Handle dependent slots in pattern-matching null tests. #39625
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
|
@agocke @RikkiGibson Could you please review this? #Closed |
|
Done with review pass (iteration 4) #Closed |
|
@agocke Could you please review this? @RikkiGibson I think I have responded to all of your comments. Do you have any more? #Closed |
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs
Outdated
Show resolved
Hide resolved
RikkiGibson
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.
![]()
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs
Show resolved
Hide resolved
|
Done review pass (commit 5) #Closed |
src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesVsPatterns.cs
Show resolved
Hide resolved
333fred
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 (commit 6)
|
@dotnet/roslyn-compiler Can I get a Sr engineer to review this, please? #Closed |
| // with another state, those dependent states won't pollute values from the other state. | ||
| private void MarkDependentSlotsNotNull(int slot, TypeSymbol expressionType, ref LocalState state) | ||
| { | ||
| foreach (var member in expressionType.GetMembers()) |
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.
foreach (var member [](start = 12, length = 19)
If expressionType has a member of the same type (a Next field for instance), won't we create many slots in this method? #Resolved
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.
Yes, we certainly will. There is a test for that. #Resolved
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.
As we discussed, would it be better to go one level deep only? That should address common cases without creating too many slots.
In reply to: 359603638 [](ancestors = 359603638)
| if (childSlot > 0) | ||
| { | ||
| state[childSlot] = NullableFlowState.NotNull; | ||
| MarkDependentSlotsNotNull(childSlot, member.GetTypeOrReturnType().Type, ref 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.
This certainly seems to work, but I can't figure out what the base case in this recursion is. #Resolved
| } | ||
| } | ||
|
|
||
| IEnumerable<Symbol> getMembers(TypeSymbol type) |
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.
IEnumerable [](start = 12, length = 11)
static? #Resolved
|
|
||
| yield break; | ||
|
|
||
| NamedTypeSymbol effectiveBase(TypeSymbol type) => type switch |
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.
NamedTypeSymbol [](start = 16, length = 15)
static #Resolved
| var t => t.BaseTypeNoUseSiteDiagnostics, | ||
| }; | ||
|
|
||
| ImmutableArray<NamedTypeSymbol> inheritedInterfaces(TypeSymbol type) => type switch |
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.
ImmutableArray [](start = 16, length = 14)
static #Resolved
|
@cston I think I've addressed all of your comments. Do you have any others? |
* 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) ...
Fixes #39264