[Issue 9777] New: Calling final interface method leads to wrong code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 21 08:21:44 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9777

           Summary: Calling final interface method leads to wrong code
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: johannespfau at gmail.com


--- Comment #0 from Johannes Pfau <johannespfau at gmail.com> 2013-03-21 08:21:43 PDT ---
Test case:

----
import core.stdc.stdio;
interface Timer
{
   final int run() { printf("Timer.run()\n"); fun(); return 1; };
   int fun();
}
interface Application
{
   final int run() { printf("Application.run()\n"); fun(); return 2; };
   int fun();
}

class TimedApp : Timer, Application
{
   int fun()
   {
       printf("TimedApp.fun()\n");
       return 0;
   }
}

void main()
{
   auto app = new TimedApp;
   (cast(Application)app).run();
   (cast(Timer)app).run();
   app.Application.run(); //fun not called
   app.Timer.run(); //fun not called
}
---

Note how "TimedApp.fun()" is not called when using app.Interface.fun. The
reason is that the wrong this pointer is passed to the interface functions. For
more information see http://forum.dlang.org/post/ki4gfp$295t$1@digitalmars.com

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list