Thread overview |
---|
July 29, 2008 [Issue 2252] New: Sequence of super interfaces matters | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2252 Summary: Sequence of super interfaces matters Product: D Version: 1.033 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: benoit@tionex.de import std.stdio; version=PROBLEM; interface I1 { void foo(); } interface IConsts { } version(PROBLEM){ interface I2 : IConsts, I1 { void bar(); } } else{ interface I2 : I1, IConsts { void bar(); } } class C1 : I1 { void foo() { writefln("foo"); } } class C2 : C1, I2 { void bar() { writefln("bar"); } void bar2() { writefln("bar"); } } void main() { C2 c2 = new C2(); c2.foo(); c2.bar(); } //------------------------------------- If version=PROBLEM is set, the error given is: class t.C2 interface function I1.foo is not implemented -- |
July 30, 2008 [Issue 2252] Sequence of super interfaces matters | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2252 ------- Comment #1 from 2korden@gmail.com 2008-07-29 19:04 ------- The following example has no workaround: import std.stdio; interface I1 { void foo1(); } interface I2 { void foo2(); } interface I3 : I1, I2 { void bar(); } class C1 : I1, I2 { void foo1() { writefln("foo1"); } void foo2() { writefln("foo2"); } } class C2 : C1, I3 { void bar() { writefln("bar"); } } void main() { C2 c2 = new C2(); c2.foo1(); c2.foo2(); c2.bar(); } -- |
July 30, 2008 [Issue 2252] Sequence of super interfaces matters | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2252 ------- Comment #2 from 2korden@gmail.com 2008-07-29 19:25 ------- Just to make it more clear: last example produces the following error message: test.d(20): class test.C2 interface function I2.foo2 is not implemented because of this line: interface I3 : I1, I2 { /* ... */ } I1 somehow shadows I2 and its implementation is not found in C2. exchanging an interface declaration order: interface I3 : I2, I1 { /* ... */ } unhides I2 implementation but hides I1's one: test.d(20): class test.C2 interface function I1.foo1 is not implemented. -- |
November 24, 2008 [Issue 2252] Sequence of super interfaces matters | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2252 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg@iname.com Keywords| |accepts-invalid ------- Comment #3 from smjg@iname.com 2008-11-24 08:24 ------- ISTM the bug is actually that the original code compiles without version=PROBLEM, rather than that it fails with. http://www.digitalmars.com/d/1.0/interface.html "A reimplemented interface must implement all the interface functions, it does not inherit them from a super class" C2 reimplements I1, albeit indirectly. So the code should be class C2 : C1, I2 { void foo() { super.foo(); } void bar() { writefln("bar"); } void bar2() { writefln("bar"); } } You could argue that indirect reimplementation should be exempt from this requirement, but that would be an enhancement request. -- |
Copyright © 1999-2021 by the D Language Foundation