class B { ~this() {} } class C : B { // NOTICE: No destructor } void main() { static assert(__traits(hasMember, B, "__dtor")); static assert(!__traits(hasMember, C, "__dtor"), "C should not have a `__dtor` member"); static assert(__traits(hasMember, B, "__xdtor")); static assert(__traits(hasMember, C, "__xdtor")); } Since `C` does not have an implementation for `~this()` it should not have a `__dtor` member. Both `B` and `C` should have an `__xdtor` member, though. (At least that is my understanding)
I think that this report is invalid. For classes you use the derivedMembers traits to see if a particular generation introduce new members. hasMember will work in combination with allMembers which doesn't make the difference.
Thanks Basile-z. I think you're right. I'll close this.
Basile-z's comment is correct. Proof: class A { ~this() {} } class B : A { } class C : A { ~this() {} } // A and B's __dtor are the same: static assert( __traits(isSame, __traits(getMember, A, "__dtor"), __traits(getMember, B, "__dtor"))); // A and C's are not: static assert(!__traits(isSame, __traits(getMember, A, "__dtor"), __traits(getMember, C, "__dtor")));