http://d.puremagic.com/issues/show_bug.cgi?id=4511


Michal Minich <michal.min...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michal.min...@gmail.com


--- Comment #1 from Michal Minich <michal.min...@gmail.com> 2010-12-09 01:16:45 
PST ---
Slightly extended example shows that the returned instance is of type derived!,
but constructor is not called.

class Base {}

class Derived : Base { this () { x = 1; }  int x; }

abstract class Abstract {
    abstract Base foo();
}

class Concrete : Abstract {
    override Derived foo() {
        return new Base;
    }
}

void main() {
    auto c = new Concrete;
    auto x = c.foo();
    writeln (typeof(x).stringof); // prints Derived (even it is result of 'new
Base')
    writeln (x.x); // prints 0 (wich means Derived's constructor is not called)
    x.x = 2;
    writeln (x.x); // prints 2
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to