https://issues.dlang.org/show_bug.cgi?id=13833
Kenji Hara <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|.classinfo.name (and |.classinfo.name (and |typeid(obj)) does not print |typeid(obj)) does not print |proper dynamic type when |proper dynamic type when |using a templated interface |using an interface --- Comment #2 from Kenji Hara <[email protected]> --- The issue also happens with non-template interface. interface I { } class D : I { } void main() { I i = new D; writeln(typeid(i)); writeln(i.classinfo.name); // ditto } Currently typeid() on interface reference returns the TypeInfo of "most derived" implemented interface. import std.stdio; interface I {} interface J : I {} interface K : I {} class E : J, K {} void main() { E e = new E; J j = e; K k = e; I ij = j; I ik = k; writeln(typeid(ij)); // prints 'test.J' writeln(typeid(ik)); // prints 'test.K' } The interface references ij an ik point different positions of class instance e, so the two typeid()s also return different TypeInfo objects. --
