digitalmars.D.bugs - Interface inheritance
- Mandeep Singh Brar (26/26) Dec 12 2010 The following code does not compile.
- Simen kjaeraas (5/31) Dec 12 2010 http://d.puremagic.com/issues/enter_bug.cgi
The following code does not compile.
import std.stdio;
interface A {
public void a(int l);
}
class ACl:A {
public void a(int l) {
writeln("Hello a");
}
}
interface B: A {
public void a(string l, int k);
}
class BCl: ACl, B {
public void a(string l, int k) {
writeln("Hello B.a", l, k);
}
}
int main() {
B b = new BCl();
b.a(1);
return 0;
}
However casting B to A like (cast(A)b).a(1); makes it work.
Regards
Mandeep
Dec 12 2010
Mandeep Singh Brar <mandeep brars.co.in> wrote:
The following code does not compile.
import std.stdio;
interface A {
public void a(int l);
}
class ACl:A {
public void a(int l) {
writeln("Hello a");
}
}
interface B: A {
public void a(string l, int k);
}
class BCl: ACl, B {
public void a(string l, int k) {
writeln("Hello B.a", l, k);
}
}
int main() {
B b = new BCl();
b.a(1);
return 0;
}
However casting B to A like (cast(A)b).a(1); makes it work.
Regards
Mandeep
http://d.puremagic.com/issues/enter_bug.cgi
Please file the bug here.
--
Simen
Dec 12 2010








"Simen kjaeraas" <simen.kjaras gmail.com>