Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 11, 2005 Covariance doesn't work on forward-referenced classes | ||||
---|---|---|---|---|
| ||||
Using DMD 0.111, Windows 98SE. The compiler refuses to accept a covariant return type that is forward referenced. Hence it is impossible for two classes to use each other as covariant return types (unless one is nested within the other). ---------- class Qwert { Qwert yuiop() { return new Qwert; } } class Asdfg : Qwert { override Hjkl yuiop() { return new Hjkl; } } class Hjkl : Qwert { override Asdfg yuiop() { return new Asdfg; } } ---------- D:\My Documents\Programming\D\Tests\bugs\covariant3.d(6): function covariant3.Asdfg.yuiop of type Hjkl () overrides but is not covariant with covariant3.Qwert.yuiop of type Qwert () ---------- The same occurs if the two classes are defined in separate modules (in which case compiling module A reports an error in module B, and vice versa). Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
February 12, 2005 Re: Covariance doesn't work on forward-referenced classes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon Attachments: | Stewart Gordon wrote: | Using DMD 0.111, Windows 98SE. | | The compiler refuses to accept a covariant return type that is forward | referenced. Hence it is impossible for two classes to use each other as | covariant return types (unless one is nested within the other). | | ---------- | class Qwert { | Qwert yuiop() { return new Qwert; } | } | | class Asdfg : Qwert { | override Hjkl yuiop() { return new Hjkl; } | } | | class Hjkl : Qwert { | override Asdfg yuiop() { return new Asdfg; } | } | ---------- | D:\My Documents\Programming\D\Tests\bugs\covariant3.d(6): function | covariant3.Asdfg.yuiop of type Hjkl () overrides but is not covariant | with covariant3.Qwert.yuiop of type Qwert () | ---------- | | The same occurs if the two classes are defined in separate modules (in | which case compiling module A reports an error in module B, and vice | versa). | | Stewart. | Added to DStress as http://dstres.kuehne.cn/run/overload_17.d http://dstres.kuehne.cn/run/overload_18.d Thomas |
February 14, 2005 Re: Covariance doesn't work on forward-referenced classes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | Thomas Kühne wrote: <snip> > Added to DStress as > http://dstres.kuehne.cn/run/overload_17.d > http://dstres.kuehne.cn/run/overload_18.d Surely this is override, not overload? Or are you using "override" to mean issues specific to the override keyword? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
February 18, 2005 Re: Covariance doesn't work on forward-referenced classes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon Attachments: | Stewart Gordon wrote: | Thomas Kühne wrote: | <snip> | |> Added to DStress as |> http://dstress.kuehne.cn/run/overload_17.d |> http://dstress.kuehne.cn/run/overload_18.d | | Surely this is override, not overload? Or are you using "override" to | mean issues specific to the override keyword? "override" is specific to the "override" keyword. "overload" contains general problems with functions' signatures. Thomas |
Copyright © 1999-2021 by the D Language Foundation