Skip to content
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

Suppress ref readonly warnings for collection initializers #69307

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

jjonescz
Copy link
Member

@jjonescz jjonescz commented Aug 1, 2023

Inspired by similar changes for interpolated string handlers and extension method receivers.
Speclet change: dotnet/csharplang@8e5c156
Test plan: #68056

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 1, 2023
@jjonescz jjonescz added the Feature - Ref Readonly Parameters `ref readonly` parameters label Aug 1, 2023
@jjonescz jjonescz requested a review from jcouv August 1, 2023 10:44
@jjonescz jjonescz marked this pull request as ready for review August 1, 2023 10:44
@jjonescz jjonescz requested a review from a team as a code owner August 1, 2023 10:44
@@ -145,7 +145,7 @@ private BoundExpression MakeDynamicCollectionInitializer(BoundExpression rewritt
Debug.Assert(addMethod.Name == "Add");
Debug.Assert(addMethod.Parameters
.Skip(addMethod.IsExtensionMethod ? 1 : 0)
.All(p => p.RefKind == RefKind.None || p.RefKind == RefKind.In));
.All(p => p.RefKind is RefKind.None or RefKind.In or RefKind.RefReadOnlyParameter));
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this change is already included in parallel PR 8beb44d.

@jcouv jcouv self-assigned this Aug 1, 2023
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 1)

@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Aug 1, 2023
@jcouv jcouv added this to the 17.8 milestone Aug 1, 2023
@jjonescz
Copy link
Member Author

jjonescz commented Aug 2, 2023

@dotnet/roslyn-compiler for a second review, thanks

@jjonescz jjonescz enabled auto-merge (squash) August 10, 2023 08:12
@jjonescz jjonescz merged commit 525d095 into dotnet:main Aug 10, 2023
@jjonescz jjonescz deleted the RefReadonly-23-CollectionInitializer branch August 10, 2023 09:33
@ghost ghost modified the milestones: 17.8, Next Aug 10, 2023
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants