Bug 21677 – Inconsistency on when override is allowed for interface methods

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-03T03:48:31Z
Last change time
2022-07-07T13:09:07Z
Assigned to
No Owner
Creator
Andrej Mitrovic

Comments

Comment #0 by andrej.mitrovich — 2021-03-03T03:48:31Z
This might be a dupe. ----- interface I1 { void foo (); } interface I2 : I1 {} void main () { class C1 : I2 { // fine override void foo () { } } abstract class B : I2 { } class C2 : B { // error? override void foo () { } // OK: // void foo () { } } } ----- I'm not sure if this is by design, but the compiler seems to disallow using the `override` keyword for implementing interface methods when there is an intermediate base class in-between. It makes it harder to write self-documenting code because I have to get rid of `override` and then it's not obvious that the method implements something from the interface.
Comment #1 by andrej.mitrovich — 2022-07-07T13:09:07Z
It seems to work nowadays.