Bug 12102 – Testing presence of member functions with same name but different signature fails

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-02-07T13:21:00Z
Last change time
2015-05-19T00:07:35Z
Assigned to
nobody
Creator
xammy

Comments

Comment #0 by xammy — 2014-02-07T13:21:14Z
The check of MyClass.func(MyClass.A) and MyClass.func(MyClass.B) in the main() function succeeds, but the alias line *in* the class definition fails with "template instance main.ConditionalUse!(MyClass) does not match template declaration ConditionalUse(T) if (hasFuncs!T)". If I rename func to funcA and funcB (making the name unambiguous), both checks succeed. Is this a bug? template hasFuncs(T) // Checks presence of T.func(T.A) and T.func(T.B) { enum bool hasFuncs = is(typeof((T t, T.A a){ t.func(a); })) && is(typeof((T t, T.B b){ t.func(b); })); } struct ConditionalUse(T) if (hasFuncs!T) { } // This line fails with // // template instance main.ConditionalUse!(MyClass) does not // match template declaration ConditionalUse(T) if (hasFuncs!T) class MyClass { struct A {} struct B {} alias ConditionalUse!MyClass Foo; void func(A a) { } void func(B b) { } } int main(char[][] args) { static assert(hasFuncs!MyClass); // This assert succeeds. return 0; }
Comment #1 by dlang-bugzilla — 2015-05-19T00:07:35Z
Works in git master. Fixed by https://github.com/D-Programming-Language/dmd/pull/4430 *** This issue has been marked as a duplicate of issue 12983 ***