Restriction on interface function types
monarch_dodra
monarchdodra at gmail.com
Wed Mar 12 04:12:59 PDT 2014
On Wednesday, 12 March 2014 at 10:57:10 UTC, Steve Teale wrote:
> interface I
> {
> auto myType();
> }
>
> class A: I
> {
> auto myType() { return cast(A) null; }
> }
>
> void main()
> {
> I x = getSomeI();
> typeof(x.myType()) y;
> }
Seems like you want covariance? I don't see how else having an
interface that returns "auto" could work.
That said, I'd expect this to work:
//----
interface I
{
I myType();
}
class A: I
{
//auto myType() { return cast(A) null; } //Nope
A myType() { return cast(A) null; } //OK
}
//----
But app
More information about the Digitalmars-d
mailing list