[Issue 21677] New: Inconsistency on when override is allowed for interface methods
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 3 03:48:31 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21677
Issue ID: 21677
Summary: Inconsistency on when override is allowed for
interface methods
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: andrej.mitrovich at gmail.com
This might be a dupe.
-----
interface I1 { void foo (); }
interface I2 : I1 {}
void main ()
{
class C1 : I2
{
// fine
override void foo () { }
}
abstract class B : I2 { }
class C2 : B
{
// error?
override void foo () { }
// OK:
// void foo () { }
}
}
-----
I'm not sure if this is by design, but the compiler seems to disallow using the
`override` keyword for implementing interface methods when there is an
intermediate base class in-between.
It makes it harder to write self-documenting code because I have to get rid of
`override` and then it's not obvious that the method implements something from
the interface.
--
More information about the Digitalmars-d-bugs
mailing list