Comment #0 by matti.niemenmaa+dbugzilla — 2006-12-17T08:38:45Z
Under "Overloading == and !=" the spec claims that "if (a == null)" is converted to "if (a.opCmp(null))", when it is actually converted to "if (a.opEquals(null))". This has been reported a few times now, but left unfixed.
Proof: the following program outputs "opEquals\nopEquals\nopCmp\n" and not "opCmp\nopEquals\nopCmp\n":
class Foo {
override int opEquals(Object o) {
printf("opEquals\n");
return 0;
}
override int opCmp(Object o) {
printf("opCmp\n");
return 0;
}
}
void main() {
Foo f = new Foo();
if (f == null) {}
if (f.opEquals(null)) {}
if (f.opCmp(null)) {}
}