Bug 2794 – Compatibility between class and interface

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-04-03T14:26:00Z
Last change time
2015-06-09T01:18:22Z
Assigned to
nobody
Creator
benoit

Comments

Comment #0 by benoit — 2009-04-03T14:26:27Z
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.
Comment #1 by benoit — 2009-04-03T14:33:51Z
I changed to D2 compiler.
Comment #2 by yebblies — 2011-06-10T08:59:07Z
*** This issue has been marked as a duplicate of issue 4088 ***