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

Add more ref readonly tests and address comments #69183

Merged
merged 8 commits into from
Jul 28, 2023

Conversation

jjonescz
Copy link
Member

@jjonescz jjonescz commented Jul 24, 2023

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 Jul 24, 2023
@jjonescz jjonescz added the New Feature - Ref Readonly Parameters `ref readonly` parameters label Jul 24, 2023
@jjonescz jjonescz requested review from AlekseyTs and jcouv July 24, 2023 13:50
@jjonescz jjonescz marked this pull request as ready for review July 24, 2023 13:50
@jjonescz jjonescz requested a review from a team as a code owner July 24, 2023 13:50
@@ -386,6 +386,9 @@ internal sealed class MemberSignatureComparer : IEqualityComparer<Symbol>
_typeComparison = typeComparison;
Debug.Assert((_typeComparison & TypeCompareKind.FunctionPointerRefMatchesOutInRefReadonly) == 0,
$"Rely on the {nameof(refKindCompareMode)} flag to set this to ensure all cases are handled.");
Debug.Assert((_refKindCompareMode & RefKindCompareMode.AllowRefReadonlyVsInMismatch) == 0 ||
(_refKindCompareMode & RefKindCompareMode.ConsiderDifferences) != 0,
$"Cannot set {nameof(RefKindCompareMode.AllowRefReadonlyVsInMismatch)} without {nameof(RefKindCompareMode.ConsiderDifferences)}.");
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 24, 2023

Choose a reason for hiding this comment

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

Consider making the assert more general. I.e. either _refKindCompareMode == DoNotConsiderDifferences, or the ConsiderDifferences flag is set. #Closed

}

[Fact]
public void ExpressionTrees()
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 24, 2023

Choose a reason for hiding this comment

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

ExpressionTrees

I think we also should test calling methods with ref readonly parameters inside an expression tree, With all possible call site modifiers, including none. Also, passing an rValue case. #Closed

@@ -4606,6 +4734,30 @@ static void Main()
Diagnostic(ErrorCode.WRN_OverridingDifferentRefness, "M2").WithArguments("in int x", "ref readonly int x").WithLocation(9, 12));
}

[Fact]
public void Implementation_RefReadonly_In_Close()
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 24, 2023

Choose a reason for hiding this comment

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

Implementation_RefReadonly_In_Close

What is the goal of the test? Should we test success scenario instead by making the methods in C public? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the point is to test MemberSignatureComparer.CSharpCloseImplicitImplementationComparer

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 5)

@jjonescz jjonescz requested a review from AlekseyTs July 25, 2023 09:56
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 8)

@jjonescz jjonescz changed the base branch from features/RefReadonly to main July 26, 2023 16:43
@jjonescz
Copy link
Member Author

@jcouv for a second review, thanks

@@ -783,6 +783,21 @@ private static void SubstituteConstraintTypes(ImmutableArray<TypeWithAnnotations
}

return true;

static bool areRefKindsCompatible(RefKindCompareMode refKindCompareMode, RefKind refKind1, RefKind refKind2)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks. This was much easier to follow :-)

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 8)

@jcouv jcouv self-assigned this Jul 27, 2023
@jcouv jcouv added this to the 17.8 milestone Jul 27, 2023
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jul 27, 2023
@jjonescz jjonescz merged commit 218d39d into dotnet:main Jul 28, 2023
25 checks passed
@jjonescz jjonescz deleted the RefReadonly-19-Tests branch July 28, 2023 07:28
@ghost ghost modified the milestones: 17.8, Next Jul 28, 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