Bug 9777 – Calling final interface method leads to wrong code
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-21T08:21:00Z
Last change time
2015-06-09T05:10:40Z
Keywords
wrong-code
Assigned to
nobody
Creator
johannespfau
Comments
Comment #0 by johannespfau — 2013-03-21T08:21:43Z
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/[email protected]