Comment #0 by bearophile_hugs — 2011-07-24T06:04:20Z
Wrong D2 code:
class Foo {
void method(int x) {}
void method(double x) {}
}
class Bar : public Foo { // line 5
override void method(int x) {}
}
void main() {
Foo f = new Bar();
f.method(1);
f.method(1.5);
}
DMD 2.054 gives the error:
test.d(5): Error: class test.Bar use of test.Foo.method(double x) hidden by Bar is deprecated
While this program gives no errors:
class Foo {
void method(int x) {}
void method(double x) {}
}
class Bar : public Foo {
alias Foo.method method;
override void method(int x) {}
}
void main() {
Foo f = new Bar();
f.method(1);
f.method(1.5);
}
In the error message I suggest to add some reference to this usage of alias, because in D.learn I've seen some D programmers blocked by this error message.
A possible message (also note the error line number, 6 instead of 5):
test.d(6): Error: class test.Bar use of test.Foo.method(double x) hidden by Bar is deprecated. Use alias Foo.method method; if intended.
Or even, to be more clear:
test.d(6): Error: class test.Bar use of test.Foo.method(double x) hidden (not overridden) by Bar is deprecated. Use alias Foo.method method; if intended.
Comment #1 by bearophile_hugs — 2011-07-26T08:24:32Z
Comment #2 by bearophile_hugs — 2011-07-26T08:27:28Z
Raised importance from minor to normal because already 4 persons have asked for help on this.
Comment #3 by bearophile_hugs — 2011-07-27T18:50:27Z
Created attachment 1013
diff to toobj.c
A kind of patch over dmd 2.054, probably wrong. Be kind.
Comment #4 by code — 2011-07-28T10:40:11Z
Besides the fact that pull requests are preferred for cases where you are reasonably sure that you patch is worth closer inspection/inclusion, please use the unified diff format (diff -u) for patches. It it the de-facto standard in the open source world and makes it easier to review changes.
Comment #5 by andrej.mitrovich — 2012-11-29T07:59:19Z