Bug 4182 – alias of base function does not transfer covariance

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-05-13T05:12:30Z
Last change time
2024-12-13T17:52:20Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: dmd#18233 →

Comments

Comment #0 by schveiguy — 2010-05-13T05:12:30Z
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.
Comment #1 by robert.schadek — 2024-12-13T17:52:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18233 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB