[Issue 2794] New: Compatibility between class and interface

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 3 12:26:23 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2794

           Summary: Compatibility between class and interface
           Product: D
           Version: 1.042
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: benoit at tionex.de


Object references and those to interfaces shall be compatible.

//-----------------------------------------------------
interface I {}
I i1 = getInstance();
I i2 = getAnotherInstance();
Object[] array;
// this does not compile, but it should:
bool res = (i1 == i2);
array ~= i1;
// instead this is atm needed:
bool res = (cast(Object)i1).opEquals( cast(Object) i2 );
array ~= cast(Object)i1;
//-----------------------------------------------------

That implies, each interface shall have the methods from Object.
Each interface shall be implicit castable to Object.

For the case, an interface is derived from IUnknown the compiler can handle
those interfaces special, and remove the compatibility.


-- 



More information about the Digitalmars-d-bugs mailing list