[Bug 65] Strange results overriding interface return with class return

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 3 12:43:03 PDT 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=65


deewiant at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |deewiant at gmail.com




------- Comment #2 from deewiant at gmail.com  2006-04-03 14:43 -------
I presume this is related, though not quite the same - the return type is not
overridden, only the type of what is returned. If that made any sense. Testcase
follows:

------------------
interface I {
        I[] foo();
        uint x();
}

class Class : I {
        I[] foo() {
                // changing this to I[] f = new Class[1] fixes the bug
                Class[] f = new Class[1];
                f[0] = new Class;
                return f;
        }

        uint x() {
                return 0;
        }
}

void main() {
        Class c = new Class();
        assert (c.x == 0);
        assert (c.foo[0].x == 0);
}
------------------

Note also the array of length 1 - if "new Class" is returned directly, the code
generated is fine.


-- 




More information about the Digitalmars-d-bugs mailing list