Attributes not propagating to objects via typeinfo?
Timon Gehr via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 14 08:39:39 PDT 2015
On 08/13/2015 06:05 PM, Steven Schveighoffer wrote:
> On 8/13/15 11:59 AM, Steven Schveighoffer wrote:
>
>> That is definitely a bug. It's because typeid is looking up the derived
>> type via the vtable, but the compiler should rewrap it with 'shared'
>> afterwards.
>
> Actually, now that I think about it, I'm not sure how the compiler can
> figure this out.
>
> There would have to be a way to construct a TypeInfo_Shared at runtime,
> which the compiler shouldn't be doing. Alternatively, it could
> proactively create a TypeInfo_Shared (and all the other flavors) for
> each class type in the runtime, and then look it up using some hash
> mechanism.
> ...
Can't the shared typeinfo be constructed for all superclasses of C at
the point where shared(C) is used? (Think: template instantiation.)
> This likely isn't fixable.
> ...
I don't understand. It is evidently fixable. E.g. if TypeInfo was just a
template without the mostly redundant additional compiler support, this
would be a trivial fix.
More information about the Digitalmars-d-learn
mailing list