-
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
Use correct get / set inside ref safety analysis #73842
Conversation
This code path for checking the receiver is unnecessary. The receiver is included in `escapeArguments` below where the same check happens. Added a test that hit the old code path and failed and verified it still fails after this change. closes dotnet#73550
@@ -409,10 +518,12 @@ private BoundExpression CheckValue(BoundExpression expr, BindValueKind valueKind | |||
switch (expr.Kind) | |||
{ | |||
case BoundKind.PropertyGroup: | |||
expr = BindIndexedPropertyAccess((BoundPropertyGroup)expr, mustHaveAllOptionalParameters: false, diagnostics: diagnostics); | |||
if (expr is BoundIndexerAccess indexerAccess) | |||
{ |
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.
Put this inside { ... }
blocks as it's now declaring variables.
@@ -2474,17 +2615,6 @@ private static string GetInvocationParameterName(ParameterSymbol? parameter) | |||
Error(diagnostics, errorCode, syntax, symbol, parameterName); | |||
} | |||
|
|||
private bool UseUpdatedEscapeRulesForInvocation(Symbol symbol) |
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.
Moved to MethodInfo.UseUpdatedEscapeRules
// https://github.com/dotnet/roslyn/issues/73550: | ||
// We do not have a test that demonstrates that the statement below makes a difference. | ||
// If it is commented out, not a single test fails | ||
escapeTo = GetValEscape(receiverOpt, scopeOfTheContainingExpression); |
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 is indeed unnecessary. Thinking through the check for IsReceiverRefReadOnly
is what caused me to dig into the get / set
issues with indexers though.
@@ -1961,21 +2091,6 @@ bool isRefEscape | |||
return escapeScope; | |||
} | |||
|
|||
private static bool ReturnsRefToRefStruct(Symbol symbol) |
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.
Moved to MethodInfo.ReturnsRefToRefStruct
@dotnet/roslyn-compiler PTAL |
1 similar comment
@dotnet/roslyn-compiler PTAL |
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.
A few suggestions, but nothing blocking.
Co-authored-by: Rikki Gibson <[email protected]>
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
This fixes a few cases where our code looked at the wrong accessor when doing ref safety analysis.
closes #35606
closes #73550
related #73872
related dotnet/csharplang#8253