TypeInfo of interfaces bugg or feature?

TheFlyingFiddle kurtyan at student.chalmers.se
Fri Dec 20 13:21:14 PST 2013


When using the typeid expression on a instance of an interface it 
gives the type of the interface not the type of the underlying 
object. Is this intended or is it a bug?


interface I { }

class A : I { }
class B : A { }

unittest
{
    A a = new A();
    B b = new B();

    writeln(typeid(a)); //Prints A
    writeln(typeid(b)); //Prints B
    a = b;
    writeln(typeid(b)); //Prints B

    I i = b;
    writeln(typeid(i)); //Prints I ????????
}


More information about the Digitalmars-d-learn mailing list