[Issue 5344] Interface Inheritance Problem
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jul 5 22:14:00 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=5344
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> ---
This is not a bug, it's normal name lookup behavior with inheritance. For
example:
class A {
void foo(int l) {}
}
class B : A {
void foo(string l, int k) {}
}
void main() {
B b = new B();
//b.foo(0); // NG, because B.foo hides A.foo
b.foo("x", 1); // OK
}
There's two options:
1. Explicitly specify the base class/interface name on the foo call.
b.A.foo(1); // OK
2. Add an alias due to insert overload in the B.foo
class B : A {
alias foo = A.foo; // OK
void foo(string l, int k) {}
}
b.foo("x", 1); // ok
b.foo(1); // also OK
--
More information about the Digitalmars-d-bugs
mailing list