Thread overview
[Issue 4647] New: Cannot explicitly call final interface method, ambiguous calls allowed
Aug 15, 2010
Andrej Mitrovic
Aug 15, 2010
Lukasz Wrzosek
Aug 15, 2010
Andrej Mitrovic
[Issue 4647] TDPL: Cannot explicitly call final interface method, ambiguous calls allowed
Oct 25, 2011
Kasumi Hanazuki
[Issue 4647] [tdpl] Cannot explicitly call final interface method, ambiguous calls allowed
Dec 26, 2011
Walter Bright
Jan 31, 2012
yebblies
August 15, 2010
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@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 15, 2010
Dnia 2010-08-15, o godz. 17:32:42
d-bugmail@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@puremagic.com
>         ReportedBy: andrej.mitrovich@gmail.com
> 
> 
> --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@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.

August 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4647



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2010-08-15 12:04:34 PDT ---
Comment from Lukasz Wrzosek
>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.

I don't see why I would need a cast. I can explicitly call methods from inherited classes, like so:

import std.stdio;

class Base
{
    void test() { writeln("Base.test()"); };
}

class Derived : Base
{
    override void test() { writeln("Derived.test()");}
}

class SecondDerived : Derived
{
}

void main()
{
    auto var = new SecondDerived;
    var.Base.test();      // calls Base.test()
    var.Derived.test();   // calls Derived.test()
}

So why shouldn't I be able to do the same with interfaces? TDPL allows it, I think it should be allowed in DMD.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4647


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@kyllingen.net
            Summary|Cannot explicitly call      |TDPL: Cannot explicitly
                   |final interface method,     |call final interface
                   |ambiguous calls allowed     |method, ambiguous calls
                   |                            |allowed
         OS/Version|Windows                     |All
           Severity|normal                      |major


--- Comment #2 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-08-16 00:05:38 PDT ---
I don't have TDPL in front of me right now, but I, too, seem to remember that this should be allowed.  Raising the priority of this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4647


Kasumi Hanazuki <k.hanazuki@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool@gmx.de


--- Comment #3 from Kasumi Hanazuki <k.hanazuki@gmail.com> 2011-10-25 12:38:15 PDT ---
*** Issue 6680 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4647


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-12-25 16:30:01 PST ---
https://github.com/D-Programming-Language/dmd/commit/4d9f2e7fd86fcdf9cbfec5c9bbad304ed125132d

https://github.com/D-Programming-Language/dmd/commit/d0fcaa80b468c455ce4b25a7af6c61fcaf749ee1

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 31, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4647


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ary@esperanto.org.ar


--- Comment #6 from yebblies <yebblies@gmail.com> 2012-01-31 13:34:12 EST ---
*** Issue 3759 has been marked as a duplicate of this issue. ***

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