Bug 4557 – Overriding static functions inherited from interfaces
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-01T14:18:00Z
Last change time
2011-06-15T07:45:33Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2010-08-01T14:18:25Z
From the page http://www.digitalmars.com/d/2.0/interface.html, the 4th example:
interface D {
void bar();
static void foo() { }
final void abc() { }
}
class C : D {
void bar() { } // ok
void foo() { } // error, cannot override static D.foo()
void abc() { } // error, cannot override final D.abc()
}
The abc() definition will error out, but the foo() one will not. This is contrary to what it states in the docs:
"Classes that inherit from an interface may not override final or static interface member functions."
Comment #1 by yebblies — 2011-06-15T07:45:33Z
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