On Fri, Jul 13, 2012 at 11:30 PM, Andrei Alexandrescu < [email protected]> wrote:
> On 7/13/12 3:18 PM, Christophe Travert wrote: > >> Andrei Alexandrescu , dans le message (digitalmars.D:172280), a écrit : >> >>> For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense >>>> because the Apple, which AppleSeed sees is the same object, which >>>> Fruit.Seed sees as it's base type Fruit. >>>> >>> >>> That would mean AppleSeed has two outer fields: a Fruit and an Apple. >>> >> >> Only one. Apple. And when AppleSeed.super seed this Apple, it sees a >> fruit. >> >> AppleSeed a; >> assert(is(typeof(a.outer) == Apple)); >> assert(is(typeof(a.super) == Seed)); >> assert(is(typeof(a.super.**outer) == Fruit)); >> //but: >> assert(a.outer is a.super.outer); >> >> If you can't figure out how can a.outer and a.super.outer have two >> different types, but be the same, think about covariant return. >> > > Makes sense, thanks. > > Andrei > > The initial question was: why does DMD 2.059 reject this if this makes sense? It's not even a new feature. It's a (possibly) new (and apparently sensible) use case of an existing feature. I came up with this when I was trying to work around the limitation of not having multiple inheritance. -- Bye, Gor Gyolchanyan.
