www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16306] New: Interface extending another interface with same

https://issues.dlang.org/show_bug.cgi?id=16306

          Issue ID: 16306
           Summary: Interface extending another interface with same method
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lodovico giaretart.net

interface A
{
    void foo();
}
interface B: A
{
    void bar();
    final void foo()
    {
        bar();
    }
}

class C: B
{
    void bar() {}
} // error: C does not implement A.foo

class D: B
{
    void foo() {}
    void bar() {}
} // error: cannot override final B.foo

So A.foo is still looked up to guarantee create the vtable, but there's no way
to provide it because B.foo is final. B.foo "hides" A.foo, without overriding
it. Why doesn't B.foo override A.foo?

This should either work as expected (B.foo overrides A.foo) or an error shall
be emitted at the definition of B.foo, because it "hides" A.foo.

See also: http://forum.dlang.org/thread/ajctidcvpndrbsotorvt forum.dlang.org

--
Jul 21 2016