I think this is trivial problem. https://github.com/D-Programming-Language/phobos/pull/199
The head of BaseClass tuple is exact super class, and we should get it. Kenji Hara 2011/8/16 Andrew Wiley <[email protected]>: > Sorry this is long, but it's a somewhat complicated issue that I think > someone who knows a lot about is() could solve very quickly. I hit this a > while back but didn't figure out exactly what the issue was until today. It > seems that std.typecons.scoped doesn't play nice with interfaces: > scopedtest.d (shortened somewhat): > import std.typecons, std.stdio; > class A { > this() { writeln("A"); } > ~this() { writeln("~A"); } > } > interface Bob {} > class ABob : A, Bob { > this() { writeln("ABob"); } > ~this() { writeln("~ABob"); } > } > void main() { auto abob = scoped!ABob(); } > > compiler output: > $ gdc -o scopedtest scopedtest.d > /usr/include/d2/4.6.0/std/typecons.d:2571: Error: template > std.typecons.destroy(T) if (is(T == class)) does not match any function > template declaration > /usr/include/d2/4.6.0/std/typecons.d:2571: Error: template > std.typecons.destroy(T) if (is(T == class)) cannot deduce template function > from argument types !()(A,Bob) > /usr/include/d2/4.6.0/std/typecons.d:2530: Error: template instance > std.typecons.destroy!(ABob) error instantiating > scopedtest.d:18: instantiated from here: scoped!(ABob,) > scopedtest.d:18: Error: template instance std.typecons.scoped!(ABob,) error > instantiating > > std.typecons.destroy: > /* > Used by scoped() above. Calls the destructors of an object > transitively up the inheritance path, but work properly only if the > static type of the object (T) is known. > */ > private void destroy(T)(T obj) if (is(T == class)) > { > static if (is(typeof(obj.__dtor()))) > { > obj.__dtor(); > } > static if (!is(T == Object) && is(T Base == super)) > { > Base b = obj; > destroy(b); // <-- this instantiation is failing > } > } > > So it looks like instead of a single type, we're getting a tuple of some > sort because ABob has multiple "superclasses" ? I haven't played with tuples > enough to know exactly what's going on here.
