Skip to content

Conversation

@jaredpar
Copy link
Member

@jaredpar jaredpar commented Jun 4, 2024

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

@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 4, 2024
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
case BoundKind.PropertyGroup:
expr = BindIndexedPropertyAccess((BoundPropertyGroup)expr, mustHaveAllOptionalParameters: false, diagnostics: diagnostics);
if (expr is BoundIndexerAccess indexerAccess)
{
Copy link
Member Author

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.

Error(diagnostics, errorCode, syntax, symbol, parameterName);
}

private bool UseUpdatedEscapeRulesForInvocation(Symbol symbol)
Copy link
Member Author

@jaredpar jaredpar Jun 13, 2024

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);
Copy link
Member Author

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.

return escapeScope;
}

private static bool ReturnsRefToRefStruct(Symbol symbol)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to MethodInfo.ReturnsRefToRefStruct

@jaredpar jaredpar marked this pull request as ready for review June 13, 2024 04:33
@jaredpar jaredpar requested a review from a team as a code owner June 13, 2024 04:33
@jaredpar
Copy link
Member Author

@dotnet/roslyn-compiler PTAL

1 similar comment
@jaredpar
Copy link
Member Author

@dotnet/roslyn-compiler PTAL

cston
cston previously approved these changes Jun 15, 2024
Copy link
Contributor

@cston cston left a 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.

@jaredpar
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jaredpar jaredpar requested a review from a team as a code owner July 12, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A test gap in CheckInvocationArgMixing method Properties with mixed readonly accessors should skip escape checks where possible

5 participants