Comment #0 by default_357-line — 2022-11-10T11:56:56Z
Comment #1 by default_357-line — 2022-11-10T11:58:26Z
Oops, pressed return too soon.
Consider this code:
--- b.d
void first(int) { }
--- a.d
import b : foo = first;
import c : foo = second;
void main() {
foo(1); // works
foo("hello"); // works
alias overloads = __traits(getOverloads, __traits(parent, foo), __traits(identifier, foo));
static assert(overloads.length == 2);
}
--- c.d
void second(string) { }
Because the overload we want is not of a struct or class, we use the common pattern, for example used in https://dlang.org/blog/category/algorithms/ , to get "the module" the overload is in. But there is no such module, because the overload is formed from two other modules that don't even use the same identifier for it.
There should be an overload or trait alternative to getOverloads that operates on a symbol directly.