-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow static members in interfaces to treat type parameters as invariant #46141
Conversation
@333fred, @RikkiGibson, @cston, @jcouv, @dotnet/roslyn-compiler Please review. |
1 similar comment
@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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Memmber -> Member #Resolved
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this 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.
dotnet/csharplang#3275
https://github.com/dotnet/csharplang/blob/master/meetings/2020/LDM-2020-06-24.md#interface-static-member-variance
https://github.com/dotnet/csharplang/blob/master/proposals/variance-safety-for-static-interface-members.md