Bug 4735 – class that implements interface can override a static method
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-26T14:18:00Z
Last change time
2011-06-15T19:48:24Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2010-08-26T14:18:14Z
According to the docs:
"Classes that inherit from an interface may not override final or static interface member functions."
module test;
void main()
{
}
interface D
{
void bar();
static void foo() { }
final void abc() { }
}
class C : D {
void bar() { } // ok
void foo() { } // passes, but should not
}
Comment #1 by yebblies — 2011-06-15T08:17:18Z
There is no error, as foo is _not_ overriding anything. If you add the
override keyword it makes this very clear:
Error: function testx.C.foo does not override any function
Comment #2 by bearophile_hugs — 2011-06-15T13:39:52Z
(In reply to comment #1)
> There is no error, as foo is _not_ overriding anything.
So what's going on here?
Comment #3 by yebblies — 2011-06-15T19:48:24Z
(In reply to comment #2)
> (In reply to comment #1)
> > There is no error, as foo is _not_ overriding anything.
>
> So what's going on here?
C is defining a virtual function with the same name as a static function in D.