July 16, 2006 typedef, implicit cast, bug or feature? | ||||
---|---|---|---|---|
| ||||
I'm not sure if this is me missing something, or if it's a bug: ******** import std.stdio; class BaseClass { int BaseProp() { return 1; } } typedef BaseClass ClassTypedef; void testfunc(ClassTypedef t) { writefln(t.BaseProp()); } ************* this gives the compiler message: test.d(9): this for BaseProp needs to be type BaseClass not type ClassTypedef The docs say that typedefs can be implicitly cast to their underlying type, so why can't t be used as a BaseClass reference? Seems like a bug to me. /Anders |
September 14, 2006 Re: typedef, implicit cast, bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders Runesson Attachments: | Anders Runesson schrieb am 2006-07-16: > I'm not sure if this is me missing something, or if it's a bug: > > ******** > import std.stdio; > > class BaseClass { > int BaseProp() { return 1; } > } > > typedef BaseClass ClassTypedef; > > void testfunc(ClassTypedef t) { writefln(t.BaseProp()); } > ************* > > this gives the compiler message: > > test.d(9): this for BaseProp needs to be type BaseClass not type > ClassTypedef > > The docs say that typedefs can be implicitly cast to their underlying > type, so why can't t be used as a BaseClass reference? Seems like a bug > to me. > /Anders Added to DStress as http://dstress.kuehne.cn/run/t/typedef_19_A.d http://dstress.kuehne.cn/run/t/typedef_19_B.d http://dstress.kuehne.cn/run/t/typedef_19_C.d http://dstress.kuehne.cn/run/t/typedef_19_D.d Thomas |
Copyright © 1999-2021 by the D Language Foundation