[Issue 4979] Implementing an interface twice results in different a reference for each interface

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 4 09:07:31 PST 2013


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



--- Comment #2 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-12-04 21:07:22 MSK ---
Currently Identity Expression over two `interface`s just compare pointers and
over an `interface` and a `class` it adds a constant dependent on operands CT
types to `class` reference and then compare pointers:
---
interface I {}
class A: I {}
class B: A, I {}

void main() @safe
{
    B b = new B;
    A a = b;
    I ia = a, ib = b;
    assert(ia is a);   // ok
    assert(ib is b);   // ok
    assert(ia is b);   // fails
    assert(ib is a);   // fails
    assert(ia is ib);  // fails
}
---

Thus Identity Expression has nothing to do with "the object references are for
the same object" except the case of two classes unless this bug is fixed.

Please confirm this bug is fixable.

Anyway if it isn't going to be fixed in the immediate future Identity
Expression over `interface`s should be appropriately documented and possibly
deprecated.

-- 
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