[Issue 4647] New: Cannot explicitly call final interface method, ambiguous calls allowed
Lukasz Wrzosek
dprogramms at gmail.com
Sun Aug 15 10:57:51 PDT 2010
Dnia 2010-08-15, o godz. 17:32:42
d-bugmail at puremagic.com napisał(a):
> http://d.puremagic.com/issues/show_bug.cgi?id=4647
>
> Summary: Cannot explicitly call final interface method,
> ambiguous calls allowed
> Product: D
> Version: D2
> Platform: Other
> OS/Version: Windows
> Status: NEW
> Severity: normal
> Priority: P2
> Component: DMD
> AssignedTo: nobody at puremagic.com
> ReportedBy: andrej.mitrovich at gmail.com
>
>
> --- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com>
> 2010-08-15 10:32:38 PDT --- Code on 2.048:
>
> import std.stdio;
>
> interface Timer
> {
> final void run() { writeln("Timer.run()"); };
> }
>
> interface Application
> {
> final void run() { writeln("Application.run()"); };
> }
>
> class TimedApp : Timer, Application
> {
> }
>
> import std.stdio;
>
> void main()
> {
> auto app = new TimedApp;
> app.Timer.run(); // error, no Timer property
> app.Application.run(); // error, no Application property
> app.run(); // This would call Timer.run() if the
> two calls // above were commented out
> }
>
> The comments state what happens.
>
> Note that if I changed the order of the TimedApp signature like so:
>
> class TimedApp : Application, Timer
>
> then the Application's run() method would be called instead of
> Timer's in the app.run() call.
>
This:
> app.Timer.run(); // error, no Timer property
> app.Application.run(); // error, no Application property
probably should be:
(cast(Timer)app).run();
(cast(Application)app).run();
But app.run() is still ambiguous - should not compile.
More information about the Digitalmars-d-bugs
mailing list