[Issue 4511] Contravariance problem
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 9 11:28:45 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4511
Sobirari Muhomori <dfj1esp02 at sneakemail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |2573
--- Comment #2 from Sobirari Muhomori <dfj1esp02 at sneakemail.com> 2010-12-09 11:27:03 PST ---
> auto c = new Concrete;
> auto x = c.foo();
> writeln (typeof(x).stringof); // prints Derived (even it is result of 'new
> Base')
You're doing it wrong.
typeof(x) is evaluated at compile time and always gives the declared type even
if x==null
The correct code is
---
auto c = new Concrete;
auto x = c.foo();
writeln(x.classinfo.name); // Base
---
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list