digitalmars.D.bugs - [Issue 4182] New: alias of base function does not transfer covariance
- d-bugmail puremagic.com (38/38) May 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4182
http://d.puremagic.com/issues/show_bug.cgi?id=4182 Summary: alias of base function does not transfer covariance Product: D Version: 2.041 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: schveiguy yahoo.com 05:12:30 PDT --- This should compile: interface I { I foo(); alias foo bar; } class C : I { C foo() { return this; } } void main() { auto c = new C; c = c.bar(); } But it doesn't, because for some reason, the compiler inserts a cast: Error: cannot implicitly convert expression ((cast(I)c).foo()) of type aliascovariance.I to aliascovariance.C Change I to a class, and the error is even more weird: Error: cannot implicitly convert expression (c.foo()) of type aliascovariance.I to aliascovariance.C As a workaround, you can repeat the alias in the derived class. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 13 2010