[Issue 16980] [REG2.072.0] wrong interface called

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 27 12:02:45 UTC 2018


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |razvan.nitu1305 at gmail.com
         Resolution|FIXED                       |---

--- Comment #8 from RazvanN <razvan.nitu1305 at gmail.com> ---
Slightly modified example:

interface A { void foo(); }
interface B { void bar(); }
interface AB : A, B {}
class C : AB {
        void foo() { assert(false, "Never called!"); }
        void bar() {}
}

struct T() {
        AB ab;
        ~this() {
                ab.bar(); // not OK, calls foo();
        }
}

static ~this()   // calling the destructor still fails
{
        tinst.__dtor();   
}

T!() tinst; // NOTE: the destructor of tinst is never run!

void main()
{
        T!() dst;
        dst.ab = new C;
        dst.ab.bar(); // OK, calls bar()
}

--


More information about the Digitalmars-d-bugs mailing list