class B
{
        void fun() { writeln("B"); }
}

class D : B
{
        override void fun() { writeln("D"); }
}

void delegate() dg = &b.fun;
dg.ptr = cast(void*)d;
dg();


Compiler: DMD 2.053
It prints "B" instead of "D".
The equivalent code in C++ prints "D" nicely.

Is it a bug or by design? I hope it's a bug coz it's smarter and more useful for delegates to handle polymorphism IMHO.

Reply via email to