[Proposal] Support generic parameters as covariant return types in overrides #9098
Replies: 1 comment 3 replies
-
It actually compiles: new B<C>();
class C
{ }
abstract class A
{
public abstract C M();
}
class B<T> : A
where T : C
{
public override T M() { throw null; }
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Today, the below code is valid:
However, this is currently not allowed:
Is this a limitation with how variance for generic parameters on classes works? Or would it be possible to enable this pattern?
Beta Was this translation helpful? Give feedback.
All reactions