On Wednesday, 12 March 2014 at 13:34:33 UTC, Steve Teale wrote:
class A : I
{
   A myType() { return cast(A)null;}
   final void foo();
}

class B : I
{
   B myType() {return cast(B) null;}
   final void bar();
}

void main()
{
   I[] arr = [new A, new B];
   foreach(i; arr) { (cast(typeof(i.myType()) i).foo() }
}

myType() is a virtual function, so calling it through the interface type should get the correct version right?, and then the cast should cause a call to A or B.

Aargh - not final void foo() and final void bar(), just void foo() in each case - a virtual function not mentioned by the interface.

Reply via email to