-
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
Factor nullability logic for placeholders #58036
Conversation
f841fb3
to
2b93066
Compare
2b93066
to
c4596a2
Compare
@@ -4177,13 +4218,22 @@ private void LearnFromNonNullTest(BoundExpression expression, ref LocalState sta | |||
{ | |||
if (expression is BoundValuePlaceholderBase placeholder) | |||
{ | |||
if (_resultForPlaceholdersOpt != null && _resultForPlaceholdersOpt.TryGetValue(placeholder, out var value)) | |||
if (PlaceholderMustBeRegistered(placeholder)) |
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.
VisitPlaceholderWithReplacement(node); | ||
return null; | ||
} | ||
|
||
private void VisitPlaceholderWithReplacement(BoundValuePlaceholderBase node) | ||
{ | ||
if (PlaceholderMustBeRegistered(node)) |
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.
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 1)
@dotnet/roslyn-compiler for second review. Small PR. Thanks |
@@ -4177,9 +4218,17 @@ private void LearnFromNonNullTest(BoundExpression expression, ref LocalState sta | |||
{ | |||
if (expression is BoundValuePlaceholderBase placeholder) | |||
{ | |||
if (_resultForPlaceholdersOpt != null && _resultForPlaceholdersOpt.TryGetValue(placeholder, out var value)) | |||
if (_resultForPlaceholdersOpt != null) |
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.
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.
Just me being stupid... :-P
SetResult(node, result.RValueType, result.LValueType); | ||
} | ||
else | ||
if (_resultForPlaceholdersOpt != null) |
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.
Debug.Assert(removed); | ||
} | ||
|
||
private bool PlaceholderMustBeRegistered(BoundValuePlaceholderBase placeholder) |
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.
Debug.Assert(removed); | ||
} | ||
|
||
private static bool PlaceholderMustBeRegistered(BoundValuePlaceholderBase placeholder) |
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 appears to only be used as an assert. Consider making this a conditional method and doing the assert directly.
default: | ||
// Newer placeholders are expected to follow placeholder discipline, namely that | ||
// they must be added to the map before they are visited, then removed. | ||
throw ExceptionUtilities.UnexpectedValue(placeholder.Kind); |
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.
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 don't see a problem with throwing as we do everywhere else. It's clear.
/azp run |
Azure Pipelines successfully started running 4 pipeline(s). |
…rovements * upstream/main: (68 commits) Lazy load ISourceLinkService to reduce DLL loads (dotnet#58108) [main] Update dependencies from dotnet/source-build (dotnet#57707) [main] Update dependencies from dotnet/arcade (dotnet#57968) Factor nullability logic for placeholders (dotnet#58036) Standardize list pattern lowering on `Index` constructor. (dotnet#58055) Add scripts to verify if a branch is ready to review Merge pull request dotnet#58100 from dotnet/dev/jorobich/skip-test Fix some places we weren't correctly disposing of VisualStudioAnalyzers Fix analyzer references being removed and added in one batch Fix indenting Ensure we don't silently capture any exceptions Don't MEF import the implementation directly if the public type will do Change comment Add comment Use actual jump tables Remove unused function Revert Simplify code Compute kind on demand Reorder ...
Introduce
NullableWalker.AddPlaceholderReplacement
andRemovePlaceholderReplacement