[Issue 1747] interface inheritance + casting ==> wrong method invoked

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 12 06:23:12 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=1747


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2014-02-12 06:22:55 PST ---
Simplified test-case:

-----
interface IA
{
    void mA();
}

interface IB : IA
{
    void mB();
}

interface IC : IB
{
}

interface ID : IA, IC
{
    void mD();
}

extern(C) int printf(in char* format, ...);

class C : ID
{
    void mA() { assert(0, "mA called"); }
    void mB() { printf("mB called\n");  }
    void mD() { assert(0, "mD called"); }
}

void main()
{
    C c = new C;
    (cast(IC)c).mB();  // ok, mB called
    (cast(IB)c).mB();  // fail, mA called
}
-----

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list