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

Allow static members in interfaces to treat type parameters as invariant #46141

Conversation

@AlekseyTs AlekseyTs requested review from 333fred, RikkiGibson, cston, jcouv and a team July 20, 2020 21:40
@AlekseyTs AlekseyTs requested a review from a team as a code owner July 20, 2020 21:40
@AlekseyTs
Copy link
Contributor Author

@333fred, @RikkiGibson, @cston, @jcouv, @dotnet/roslyn-compiler Please review.

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@333fred, @RikkiGibson, @cston, @jcouv, @dotnet/roslyn-compiler Please review.

@@ -1866,6 +1866,7 @@ internal enum ErrorCode
ERR_StaticAPIInRecord = 8877,
ERR_CopyConstructorWrongAccessibility = 8878,
ERR_NonPrivateAPIInRecord = 8879,
ERR_UnexpectedVarianceStaticMemmber = 8880,
Copy link
Contributor

@RikkiGibson RikkiGibson Jul 21, 2020

Choose a reason for hiding this comment

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

nit: Memmber -> Member #Resolved

@CyrusNajmabadi
Copy link
Member

IDE side is fine :)

parseOptions: TestOptions.Regular8,
targetFramework: TargetFramework.NetStandardLatest);
compilation1.VerifyDiagnostics(
// (13,18): error CS8880: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2<T1, T2>.M1(T1)' unless language version 'preview' or greater is used. 'T1' is covariant.
Copy link
Member

@333fred 333fred Jul 21, 2020

Choose a reason for hiding this comment

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

must be contravariantly valid [](start = 84, length = 29)

I think a better wording would be "cannot be used contra/co/invariantly". #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a better wording would be "cannot be used contra/co/invariantly".

I am sharing the wording with existing message. Changing the wording is outside of the scope of this PR


In reply to: 458353056 [](ancestors = 458353056)

Copy link
Member

@333fred 333fred 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 1). If you want to keep the wording as is to match the existing error message that's ok, but I do think the wording is a bit confusing and would work better with my suggestion.

@AlekseyTs
Copy link
Contributor Author

@cston, @jcouv Please review a relatively small fix, need a sign-off from a senior dev.

@AlekseyTs AlekseyTs merged commit 6a5ba0a into dotnet:features/VarianceSafetyForStaticMembers Jul 22, 2020
@JoeRobich JoeRobich modified the milestone: 16.8.P4 Nov 9, 2020
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.

6 participants