The aliases `self` and `parent` are both declared by aliasing the function by name. For overloaded functions this means the overloads is aliased, not the exact function being implemented. This is not a problem when just calling `self` or `parent`, but for reflection purposes it is.
The following should work, but doesn't:
----------
import std.typecons : AutoImplement;
interface A
{
void overloaded(int);
void overloaded(float);
}
enum tpl(C, alias fun) = q{
import std.traits : Parameters;
static assert(is(Parameters!self == typeof(args)));
};
alias Impl = AutoImplement!(A, tpl);
----------
Output:
$ dmd -o- -c autoimplement.d
/Library/D/dmd/src/phobos/std/typecons.d-mixin-4495(4510): Error: static assert: is((int) == (float)) is false
autoimplement.d(14): instantiated from here: AutoImplement!(A, tpl, isAbstractFunction)
Comment #1 by dlang-bot — 2019-03-05T06:00:37Z
@thaven updated dlang/phobos pull request #6876 "Also expose 'parent' when it's abstract" mentioning this issue:
- Temporarily comment out overload in test to work around Issue 19715
https://github.com/dlang/phobos/pull/6876
Comment #2 by dlang-bot — 2022-01-18T03:54:11Z
dlang/phobos pull request #6876 "Also expose 'parent' when it's abstract" was merged into master:
- 47291bb0e6f3169737139a92b33887c7e588dd8f by thaven:
Temporarily comment out overload in test to work around Issue 19715
https://github.com/dlang/phobos/pull/6876
Comment #3 by robert.schadek — 2024-12-01T16:34:50Z