[Issue 12102] New: Testing presence of member functions with same name but different signature fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 7 13:21:16 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12102

           Summary: Testing presence of member functions with same name
                    but different signature fails
           Product: D
           Version: 2.041
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: xammy at xammy.info


--- Comment #0 from Matthias Walter <xammy at xammy.info> 2014-02-07 13:21:14 PST ---
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;
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list