Bug 13690 – Interface final method which overrides a method in the parent interface leads to unimplementable interface

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-11-05T21:46:31Z
Last change time
2020-02-28T12:19:24Z
Assigned to
No Owner
Creator
Patrick Jeeves

Comments

Comment #0 by pdj9 — 2014-11-05T21:46:31Z
The following causes dmd to segfault: import std.traits; interface BarBase { void do_a_thing(); } interface Bar(T) : BarBase { static if(hasMember!(T, "rotation") && is(typeof(T.rotation) == double)) { @property double rotation(); final void do_a_thing() { //do a thing with rotation; } } else { final void do_a_thing() { //do a thing without rotation; } } } class Foo1 : Bar!Foo1 { } class Foo2 : Bar!Foo2 { @property double rotation() { return 1.0; }; } This code is theoretically compilable because if it were changed to imitate the halting problem then: if the function is declared final then there isn't a conflict, if it isn't then the class has to be abstract.
Comment #1 by k.hara.pg — 2015-01-19T15:34:53Z
Segfault doesn't occur with git-head (2.067alpha), and the code reports following errors: test.d(10): Error: expression hasMember!(Foo1, "rotation") of type void does not have a boolean value test.d(10): Error: template instance std.traits.hasMember!(Foo1, "rotation") error instantiating test.d(28): instantiated from here: Bar!(Foo1) test.d(10): Error: expression hasMember!(Foo2, "rotation") of type void does not have a boolean value test.d(10): Error: template instance std.traits.hasMember!(Foo2, "rotation") error instantiating test.d(32): instantiated from here: Bar!(Foo2) Remove "segfault" word from the subject.
Comment #2 by razvan.nitu1305 — 2018-02-22T14:26:40Z
Running the example on dmd 2.078.0 Ubuntu 16.04 results in : test.d(27): Error: class `test.Foo1` interface function void do_a_thing() is not implemented test.d(31): Error: class `test.Foo2` interface function void do_a_thing() is not implemented test.d(31): Error: class `test.Foo2` interface function double rotation() @property is not implemented So the real problem here is this: (reduced test case) interface A { void x(); } interface B : A { final void x() { } } class C : B { //override void x() {} } If the method in C is commented you will get error stating that you are not implementing x. If you uncomment you will get an error stating that you cannot override final method. That's the real bug. Changing the title to reflect that
Comment #3 by simen.kjaras — 2020-02-28T12:19:24Z
Moving this to issue 16306, since that issue contains less noise and has a perfect example in the first comment. *** This issue has been marked as a duplicate of issue 16306 ***