Skip to content

Run ref safety analysis for field initializers on bound nodes transformed to assignments to the target fields.#69088

Merged
AlekseyTs merged 2 commits intodotnet:mainfrom
AlekseyTs:PrimaryConstructors_35
Jul 19, 2023
Merged

Run ref safety analysis for field initializers on bound nodes transformed to assignments to the target fields.#69088
AlekseyTs merged 2 commits intodotnet:mainfrom
AlekseyTs:PrimaryConstructors_35

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

Fixes #67371.

@AlekseyTs AlekseyTs requested a review from a team as a code owner July 18, 2023 16:34
@ghost ghost added the untriaged Issues and PRs which have not yet been triaged by a lead label Jul 18, 2023
@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@cston, @RikkiGibson, @jjonescz, @dotnet/roslyn-compiler Please review.

public ref int R3 = ref x;
}

ref struct S4([System.Diagnostics.CodeAnalysis.UnscopedRef] ref int x)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we also have a test for a scoped ref primary constructor parameter which is ref-assigned to ref field in a constructor and in a field initializer?

";
var comp = CreateCompilation(source, options: TestOptions.ReleaseDll, targetFramework: TargetFramework.NetCoreApp);
comp.VerifyDiagnostics();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

}

Consider adding ref readonly cases as well.

ref struct S5(in int x)
{
    ref readonly int R5 = ref x;
}

@AlekseyTs AlekseyTs enabled auto-merge (squash) July 19, 2023 13:30
@AlekseyTs AlekseyTs merged commit 9a2664f into dotnet:main Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Primary Constructors Feature - Ref Fields 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.

Ref-assigning a ref parameter to a ref field with primary constructor

3 participants