← Back to index
|
Original Bugzilla link
Bug 7552 – Cannot get and combine a part of overloaded functions
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-20T04:47:00Z
Last change time
2012-02-20T16:19:00Z
Keywords
pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0
by k.hara.pg — 2012-02-20T04:47:55Z
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](""); } ----
Comment #1
by k.hara.pg — 2012-02-20T05:02:37Z
https://github.com/D-Programming-Language/dmd/pull/748
Comment #2
by github-bugzilla — 2012-02-20T15:15:51Z
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