std.typecons.Proxy + inheritance breaks cast'ing to inherited type
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 16 05:03:11 PDT 2015
On Monday, 16 March 2015 at 09:03:18 UTC, Lukasz Wrzosek wrote:
> Hello
> I was just exploring possibility to mimic multiple inheritance
> from C++ (do not ask why, just for fun).
> I've stumbled on below issue (let's say corner case) and most
> likely this is bug in implementation of template Proxy, isn't
> it ?
>
>
> import std.typecons;
> class IA {}
> class IB {}
> class C : IB {
> IA a;
> mixin Proxy!a;
>
> public this() {
> a = new IA;
> }
> }
>
> void main() {
> C c = new C;
> IA a = cast(IA)c;
> IB b_ok = c;
> IB b_not_ok = cast(IB)c;
> assert(c !is null);
> assert(a !is null);
> assert(b_ok !is null);
> assert(b_not_ok !is null); //fails
> }
What behaviour would you expect if both IA and C inherited from
IB?
More information about the Digitalmars-d-learn
mailing list