test case:
==========
struct FiberS {
static auto getThis(){
return Fiber.getId();
}
}
struct Proxy(T){
T* ptr;
alias getPayload this; // works with "alias ptr this;"
@property ref auto getPayload() inout return {
return *ptr ;
}
static auto getId(){
return 1;
}
}
alias Fiber = Proxy!(FiberS);
struct TcpStream {
static void test(){
auto id = Fiber.getThis(); // work here
}
void read(ubyte[] data){
auto id = Fiber.getThis(); // not work here
}
}
forum discussion:
=================
https://forum.dlang.org/post/[email protected]
Comment #1 by b2.temp — 2021-05-02T01:05:11Z
much simplified:
---
struct T
{
static int target() {return 0;}
}
struct S
{
T t;
T aliasGet(){return t;}
alias aliasGet this;
}
struct Use
{
// S.aliasGet().target():
// ----------------------
// and T static members are tried
static void ok()
{
auto v = S.target();
}
// S.aliasGet(this).target():
// ----------------------
// T static members are not tried because error happens before
void bug()
{
auto v = S.target();
}
}
---
Comment #2 by robert.schadek — 2024-12-13T19:01:01Z