digitalmars.D.bugs - [Issue 2252] New: Sequence of super interfaces matters
- d-bugmail puremagic.com (45/45) Jul 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2252
- d-bugmail puremagic.com (27/27) Jul 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2252
- d-bugmail puremagic.com (13/13) Jul 29 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2252
- d-bugmail puremagic.com (21/21) Nov 24 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2252
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 --
Jul 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2252 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(); } --
Jul 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2252 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. --
Jul 29 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2252 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com Keywords| |accepts-invalid 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. --
Nov 24 2008