Thread overview
[Issue 9978] New: Can override interface function
Apr 22, 2013
Damian
Apr 22, 2013
Damian
April 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9978

           Summary: Can override interface function
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: damianday@hotmail.co.uk


--- Comment #0 from Damian <damianday@hotmail.co.uk> 2013-04-22 09:13:17 PDT ---
interface I
{
    void foo();
}

class A : I
{
    public override void foo() { } // OK, but should be NG!!
    public void foo() { } // OK
}

In this example the use of override is optional,
however since we are not overriding any function it should
be illegal to specify it as override.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9978



--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2013-04-22 10:22:51 PDT ---
I would tend to think this is allowed.  Imagine if you switched an interface to an abstract base class or vice versa, you wish to make someone go through all their calls and add/remove override?

I had a bug fixed a long time ago, issue 2524.

In a comment, Walter said:

"This is a compiler bug. You can override an interface function."

I'm assuming this still applies today.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9978



--- Comment #2 from Damian <damianday@hotmail.co.uk> 2013-04-22 11:03:58 PDT ---
(In reply to comment #1)
> I would tend to think this is allowed.  Imagine if you switched an interface to an abstract base class or vice versa, you wish to make someone go through all their calls and add/remove override?
> 
> I had a bug fixed a long time ago, issue 2524.
> 
> In a comment, Walter said:
> 
> "This is a compiler bug. You can override an interface function."
> 
> I'm assuming this still applies today.

That's precisely what I was doing when I stumbled upon this, changing a abstract class to a interface. I'm not sure why both are allowed, even though it does no harm to keep both, it seems one should be the right way and the other a warning possibly?

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