On Sun, 12 Sep 2010 17:00:54 -0400, Simen kjaeraas
<[email protected]> wrote:
Jacob Carlborg <[email protected]> wrote:
The following example doesn't compile with D2:
class Foo
{
private Object value;
synchronized bool hasValue (Object val)
{
return value == val;
}
}
It gives the error:
main.d(11): Error: function object.opEquals (Object lhs, Object rhs) is
not callable using argument types (shared(Object),Object)
main.d(11): Error: cannot implicitly convert expression (this.value) of
type shared(Object) to object.Object
Is that because object.opEquals hasn't been overloaded with a shared
version yet? If that's the case has this already been reported in
bugzilla?
You're absolutely right about the cause. This is related to, though not
the
same issue as, #1824 (http://d.puremagic.com/issues/show_bug.cgi?id=1824)
I'm unsure whether this should be added to #1824 or filed as a separate
bug.
Not exactly right. Comparing two objects has been altered significantly
since a few versions ago. Instead of a = b translating to a.opEquals(b),
it translates to opEquals(a, b). opEquals(a, b) is defined in object.di
as:
bool opEquals(Object o1, Object o2);
This means you cannot compare shared, immutable, or const objects, and you
cannot compare interfaces (because interfaces do not implicitly cast to
Object). Even if you updated Object.opEquals, it still wouldn't work.
It is a severe problem that has been ignored for quite a while (especially
the interface comparison problem).
The interface bug report:
http://d.puremagic.com/issues/show_bug.cgi?id=4088
-Steve