Thread overview
[Issue 7552] New: Cannot get and combine a part of overloaded functions
Feb 20, 2012
Kenji Hara
Feb 20, 2012
Kenji Hara
Feb 21, 2012
Walter Bright
February 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7552

           Summary: Cannot get and combine a part of overloaded functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2012-02-20 04:47:55 PST ---
Extracting a function symbol from overloads by __traits(getOverloads), and combining them by alias declaration should generate new overloads. See following code.

----
template TypeTuple(T...){ alias T TypeTuple; }
template Id(      T){ alias T Id; }
template Id(alias A){ alias A Id; }

struct S
{
    static void foo(){}
    static void foo(int){}
}

struct T
{
    alias TypeTuple!(__traits(getOverloads, S, "foo")) FooInS;
    alias FooInS[0] foo;    // should be S.foo()
    static void foo(string){}
}

struct U
{
    alias TypeTuple!(__traits(getOverloads, S, "foo")) FooInS;
    alias FooInS[1] foo;    // should be S.foo(int)
    static void foo(string){}
}

void main()
{
    alias TypeTuple!(__traits(getOverloads, S, "foo")) FooInS;
    static assert(FooInS.length == 2);
                                      FooInS[0]();
    static assert(!__traits(compiles, FooInS[0](0)));
    static assert(!__traits(compiles, FooInS[1]()));
                                      FooInS[1](0);

                                      Id!(FooInS[0])();
    static assert(!__traits(compiles, Id!(FooInS[0])(0)));
    static assert(!__traits(compiles, Id!(FooInS[1])()));
                                      Id!(FooInS[1])(0);

    alias TypeTuple!(__traits(getOverloads, T, "foo")) FooInT;
    static assert(FooInT.length == 2);                  // fail
                                      FooInT[0]();
    static assert(!__traits(compiles, FooInT[0](0)));
    static assert(!__traits(compiles, FooInT[0]("")));
    static assert(!__traits(compiles, FooInT[1]()));
    static assert(!__traits(compiles, FooInT[1](0)));   // fail
                                      FooInT[1]("");    // fail

    alias TypeTuple!(__traits(getOverloads, U, "foo")) FooInU;
    static assert(FooInU.length == 2);
    static assert(!__traits(compiles, FooInU[0]()));
                                      FooInU[0](0);
    static assert(!__traits(compiles, FooInU[0]("")));
    static assert(!__traits(compiles, FooInU[1]()));
    static assert(!__traits(compiles, FooInU[1](0)));
                                      FooInU[1]("");
}
----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7552


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-02-20 05:02:37 PST ---
https://github.com/D-Programming-Language/dmd/pull/748

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7552



--- Comment #2 from github-bugzilla@puremagic.com 2012-02-20 15:15:51 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2d23bfa74395340adf720c406678604b9704915d Merge pull request #748 from 9rnsr/fix7552

Issue 7552 - Cannot get and combine a part of overloaded functions

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7552


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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