-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-Language DesignFeature RequestLanguage-C#Language-VBResolution-ExternalThe behavior lies outside the functionality covered by this repositoryThe behavior lies outside the functionality covered by this repository
Description
Support covariant return types. Specifically, allow an overriding method to have a more derived reference type than the method it overrides. This would apply to methods and properties, and be supported in classes and interfaces. This is one possible alternative to a this type proposed in #311.
This would be useful in the factory pattern. For example, in the Roslyn code base we would have
class Compilation ...
{
virtual Compilation WithOptions(Options options)...
}class CSharpCompilation : Compilation
{
override CSharpCompilation WithOptions(Options options)...
}The implementation of this would be for the compiler to emit the overriding method as a "new" virtual method that hides the base class method, along with a bridge method that implements the base class method with a call to the derived class method.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-Language DesignFeature RequestLanguage-C#Language-VBResolution-ExternalThe behavior lies outside the functionality covered by this repositoryThe behavior lies outside the functionality covered by this repository