Thread overview
[Issue 17462] Order of base interfaces affects compiler behavior
Jan 12
RazvanN
Jan 12
RazvanN
5 days ago
Rainer Schuetze
January 12
https://issues.dlang.org/show_bug.cgi?id=17462

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
PR : https://github.com/dlang/dmd/pull/7684

--
January 12
https://issues.dlang.org/show_bug.cgi?id=17462

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=17462

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> ---
FWIW the Java code works without requiring the additional implementation:

interface Marker {}
interface Foo { void foo(); }

interface FooMarked extends Foo, Marker {}
interface MarkedFoo extends Marker, Foo  {}

class Base implements Foo { public void foo() {} }

class Derived1 extends Base implements FooMarked {} // Inherit Base.foo class Derived2 extends Base implements MarkedFoo {} // Inherit Base.foo

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=17462

Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario@gmx.de

--- Comment #3 from Rainer Schuetze <r.sagitario@gmx.de> ---
I always considered it a great relief that you don't have to reimplement common interfaces. Otherwise COM-programming would be much more verbose. What's the reasoning to disallow it?

The old samples in dmd/samples also assume that IUnknown doesn't have to be reimplemented.

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=17462

--- Comment #4 from Andrei Alexandrescu <andrei@erdani.com> ---
The following C++ equivalent does require the additional implementation (uncomment code to get it to compile):

--------------------
class Marker {};
class Foo { public: virtual void foo() = 0; };

class FooMarked : public Foo, public Marker {};
class MarkedFoo : public Marker, public Foo  {};

class Base : public Foo { virtual void foo() {} };

class Derived1 : public Base, public FooMarked {
    //virtual void foo() {}
};
class Derived2 : public Base, public MarkedFoo {
    //virtual void foo() {}
};

int main() {
    auto d1 = new Derived1;
    auto d2 = new Derived2;
}
--------------------

However, this other code, which arguably is closer in spirit, does work:

--------------------
class Marker {};
class Foo { public: virtual void foo() = 0; };

class FooMarked : virtual public Foo, public Marker {}; class MarkedFoo : public Marker, virtual public Foo  {};

class Base : virtual public Foo { virtual void foo() {} };

class Derived1 : public Base, public FooMarked {}; class Derived2 : public Base, public MarkedFoo {};

int main() {
    auto d1 = new Derived1;
    auto d2 = new Derived2;
}
--------------------

--