Issue 19715 - AutoImplement `self` and `parent` aliases are incorrect for overloaded functions
Summary: AutoImplement `self` and `parent` aliases are incorrect for overloaded functions
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 All
: P3 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-03 16:59 UTC by Harry Vennik
Modified: 2024-12-01 16:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Harry Vennik 2019-03-03 16:59:11 UTC
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 Dlang Bot 2019-03-05 06:00:37 UTC
@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 Dlang Bot 2022-01-18 03:54:11 UTC
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 dlangBugzillaToGithub 2024-12-01 16:34:50 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10367

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB