Bug 19767 – Classes that inherit from an interface can override static interface methods

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-03-27T13:34:38Z
Last change time
2024-12-13T19:02:43Z
Assigned to
Eduard Staniloiu
Creator
Eduard Staniloiu
Moved to GitHub: dmd#19547 →

Comments

Comment #0 by edi33416 — 2019-03-27T13:34:38Z
This directly contradicts the interface [spec](https://dlang.org/spec/interface.html), pt. 8: "Classes that inherit from an interface may not override final or static interface member functions." interface D { void bar(); static void foo() { } } class C : D { void bar() { } // ok void foo() { } // BUG: this is ok, but should error because we cannot override static D.foo() }
Comment #1 by b2.temp — 2019-03-27T18:18:42Z
I don't know if the report is valid. 1. You can still call the interface version of foo, e.g `(new C).D.foo();` 2. C.foo() is not virtual and does not call the inherited D.foo(). Because 2, the specs are respected. It's not an override but rather a case of hijacking.
Comment #2 by andrei — 2019-03-27T19:06:25Z
Yah, this should be clarified in the spec. Thanks Edi!
Comment #3 by robert.schadek — 2024-12-13T19:02:43Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19547 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB