Bug 12329 – override for implementing interface methods is not allowed in a subclass
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-09T06:59:00Z
Last change time
2014-07-18T11:52:29Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2014-03-09T06:59:15Z
This is likely a dupe report but I can't find the report.
-----
module test;
interface I { void foo(); }
class C : I { override void foo() { } } // ok to use override here
class D : C { override void foo() { } }
class C2 : I { }
class D2 : C2 { override void foo() { } } // error
void main() { }
-----
The compiler should be consistent, either disallow override in both cases for C and D2, or allow them both. But remember this is about *implementing* the interface function, not overriding it.
Note that the diagnostic is also terrible:
Error: function test.D2.foo does not override any function, did you mean to override 'test.I.foo'?
But I'm sure I saw this filed somewhere too.
Comment #1 by verylonglogin.reg — 2014-07-18T11:52:29Z
*** This issue has been marked as a duplicate of issue 2525 ***