D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19546 - cannot implicitly override base class method [...] add override attribute
Summary: cannot implicitly override base class method [...] add override attribute
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2019-01-03 21:53 UTC by kdevel
Modified: 2022-07-23 13:06 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kdevel 2019-01-03 21:53:13 UTC
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
Comment 1 kdevel 2019-01-03 21:58:36 UTC
https://dlang.org/spec/interface.html #11 also need the override attribute.