Bug 22232 – implementing interface function by inheriting from other class

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-08-22T12:35:56Z
Last change time
2021-08-22T13:46:08Z
Assigned to
No Owner
Creator
Alexey

Comments

Comment #0 by animuspexus — 2021-08-22T12:35:56Z
asked at Discord and at Forum, but nobody could tell if this is a bug: ```D interface Int { void coolFunc(); } class C1 { void coolFunc() { return; } } class C2 : C1, Int { } void main() { auto c = new C2; } ``` dmd ends with error: t.d(14): Error: class t.C2 interface function void coolFunc() is not implemented
Comment #1 by destructionator — 2021-08-22T13:42:36Z
This is by design, see item 13 here: https://dlang.org/spec/interface.html Even if the parent already did the interface, the spec says the interface must be implemented again. You can do it by using forwarding functions.