www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19546] New: cannot implicitly override base class method

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

          Issue ID: 19546
           Summary: cannot implicitly override base class method [...] add
                    override attribute
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

According to https://dlang.org/spec/interface.html #10 this program should
compile:

```ifa.d
interface D
{
    int foo();
}

class A : D
{
    int foo() { return 1; }
}

class B : A
{
    int foo() { return 2; }
}

void main ()
{
   import std.stdio;
   B b = new B();
   writeln (b.foo());  // returns 2
   D d = cast(D) b;    // ok since B inherits A's D implementation
   writeln (d.foo());  // returns 2;
}
```

$ dmd ifa
ifa.d(13): Error: cannot implicitly override base class method ifa.A.foo with
ifa.B.foo; add override attribute

$ dmd --version
DMD64 D Compiler v2.082.0
Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
written by Walter Bright

--
Jan 03