import std.stdio; interface SupportsTag { } interface HelloWorld { void helloWorld (); } class X : HelloWorld { void helloWorld () { writefln ("X: Hello World"); } } class Y : HelloWorld, SupportsTag { void helloWorld () { writefln ("Y: Hello World"); } } void main () { auto x = new X (); auto y = new Y (); if (cast(SupportsTag)(x)) { x.helloWorld (); } if (cast(SupportsTag)(y)) { y.helloWorld (); } HelloWorld hw; hw = x; if (cast(X)(hw)) { writefln ("1: HW is X"); } if (cast(Y)(hw)) { writefln ("1: HW is Y"); } if (cast(SupportsTag)(hw)) { hw.helloWorld (); } hw = y; if (cast(X)(hw)) { writefln ("2: HW is X"); } if (cast(Y)(hw)) { writefln ("2: HW is Y"); } if (cast(SupportsTag)(hw)) { hw.helloWorld (); } }