[Issue 19032] Alias this does not interact with inheritance.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 28 06:33:34 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19032

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras at gmail.com

--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Simplified:

class A {
    int n;
    alias n this;
}

class B : A {}

unittest {
    // Works when accessed through an A:
    static assert(__traits(compiles, cast(int)new A()));
    static assert(__traits(compiles, cast(int)cast(A)new B()));

    // Fails when accessed through a B:
    static assert(!__traits(compiles, cast(int)new B()));
}

OP also requires multiple alias this, which the documentation states is
currently unimplemented (issue 6083).

--


More information about the Digitalmars-d-bugs mailing list