Skip to content

Commit

Permalink
Merge pull request #7254 from sharwell/ref-readonly
Browse files Browse the repository at this point in the history
Improve support for RefKind.RefReadOnlyParameter in RS0042 (Do not copy value)
  • Loading branch information
sharwell authored Mar 20, 2024
2 parents 0c86a45 + 2276463 commit 8898d8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1351,9 +1351,8 @@ private static bool CanAssign(RefKind sourceRefKind, RefKind targetRefKind)
return (sourceRefKind, targetRefKind) switch
{
(RefKind.None, _) => true,
(RefKind.Ref, RefKind.Ref) => true,
(RefKind.Ref, RefKind.RefReadOnly or RefKindEx.RefReadOnlyParameter) => true,
(RefKind.RefReadOnly, RefKind.RefReadOnly or RefKindEx.RefReadOnlyParameter) => true,
(RefKind.Ref, RefKind.Ref or RefKind.RefReadOnly or RefKindEx.RefReadOnlyParameter) => true,
(RefKind.RefReadOnly or RefKindEx.RefReadOnlyParameter, RefKind.RefReadOnly or RefKindEx.RefReadOnlyParameter) => true,
_ => false,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ internal sealed class NonCopyableAttribute : System.Attribute {{ }}
[Theory]
[CombinatorialData]
public async Task AllowUnsafeAsRefParameterReference2Async(
[CombinatorialValues("ref", "in")] string parameterModifiers,
[CombinatorialValues("ref", "in", "ref readonly")] string parameterModifiers,
[CombinatorialValues("in", "scoped in", "ref readonly", "scoped ref readonly")] string asRefParameterModifiers)
{
var source = $@"
Expand Down

0 comments on commit 8898d8d

Please sign in to comment.