May 13, 2010 [Issue 4182] New: alias of base function does not transfer covariance | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-05-13 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: ------- |
Copyright © 1999-2021 by the D Language Foundation