D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12222 - "alias this" ignored for aliased methods
Summary: "alias this" ignored for aliased methods
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-21 21:35 UTC by Vladimir Panteleev
Modified: 2024-12-13 18:17 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2014-02-21 21:35:56 UTC
///// test.d /////
struct S
{
    void f() {}
}

struct W
{
    S s;
    alias s this;
    alias f = s.f;
}

void main()
{
    W w;
    w.f();
}
//////////////////

Compiler complains:

test.d(16,2): Error: this for f needs to be type S not type W

However, there is an "alias this" it W to S which should allow the method to be called with S as the "this" type.
Comment 1 RazvanN 2018-11-05 11:41:48 UTC
Why would you even do that? Isn't the alias this enough?
Comment 2 Vladimir Panteleev 2018-12-27 20:56:45 UTC
I don't remember for certain, but I think it is so that f can be passed as an alias parameter to a method of W.
Comment 3 dlangBugzillaToGithub 2024-12-13 18:17:19 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18779

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