http://d.puremagic.com/issues/show_bug.cgi?id=3055
Summary: & operator doesn't get correct func to construct the delegate Product: D Version: 2.028 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzi...@digitalmars.com ReportedBy: dav...@126.com import std.stdio; class t { void func(){writefln("t");} void delegate() getdelegate(){return &t.func; } // this doesn't return the delegate of t.func } class v:t { void func(){writefln("v");} } class r:v { void func(){writefln("r");} void delegate() getdelegate(){return t.getdelegate(); } } void main() { r p= new r; p.getdelegate()(); } h3 gave me the solution which can work correctly: import std.stdio; class t { void func(){writefln("t");} void delegate() getdelegate(){ static void function() getfuncptr() { return &func; } auto res = &func; res.funcptr = getfuncptr; return res; } } class v:t { void func(){writefln("v");} } class r:v { void func(){writefln("r");} void delegate() getdelegate(){return t.getdelegate(); } } void main() { r p= new r; p.getdelegate()(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------