digitalmars.D.learn - How does one correct shadowing (hidden by) errors?
- "Tyro[a.c.edwards]" <nospam home.com> Jul 22 2011
- Andrej Mitrovic <andrej.mitrovich gmail.com> Jul 22 2011
- bearophile <bearophileHUGS lycos.com> Jul 23 2011
- bearophile <bearophileHUGS lycos.com> Jul 23 2011
- "Tyro[a.c.edwards]" <nospam home.com> Jul 23 2011
- bearophile <bearophileHUGS lycos.com> Jul 24 2011
- bearophile <bearophileHUGS lycos.com> Jul 24 2011
- Jesse Phillips <jessekphillips+d gmail.com> Jul 23 2011
- Jesse Phillips <jessekphillips+d gmail.com> Jul 23 2011
While attempting to build the DFL libraries, I encountered the following
three errors:
[1] tabcontrol.d(18): Error: class dfl.tabcontrol.TabPage use of
dfl.control.Control.opEquals(Control ctrl) hidden by TabPage is deprecated
[2] tabcontrol.d(18): Error: class dfl.tabcontrol.TabPage use of
dfl.control.Control.opCmp(Control ctrl) hidden by TabPage is deprecated
[3] imagelist.d(22): Error: class
dfl.imagelist.ImageList.ImageCollection use of
dfl.imagelist.ImageList.ImageCollection.ListWrapArray!(Image,_images,_adding,_added,_blankListCallback,_removed,false,fal
e,false).insert(int
index, Image value) hidden by ImageCollection is deprecated
Now I know I can bypass this with the -d switch but I'm more interested
in fixing the problem than bypassing it.
Control defines the following two functions:
override Dequ opEquals(Object o)
{
Control ctrl = cast(Control)o;
if(!ctrl)
return 0; // Not equal.
return opEquals(ctrl);
}
override int opCmp(Object o)
{
Control ctrl = cast(Control)o;
if(!ctrl)
return -1;
return opCmp(ctrl);
}
Whereas TabPage defines the following:
override Dequ opEquals(Object o)
{
return text == getObjectString(o);
}
override int opCmp(Object o)
{
return stringICmp(text, getObjectString(o));
}
How does one correct this such that the latter does not hide the first?
Problem [3] on the other hand is caused by a template mixin in the
dfl.imagelist.ImageList.ImageCollection. ImageCollection is not a
derived class so I do not understand what is being hidden. Please
explain. Also, a suggestion on how to correct the issue would be
helpful. The code is as follows:
class ImageList
{
class ImageCollection
{
...
public:
mixin ListWrapArray!(Image, _images,
_adding, _added,
_blankListCallback!(Image), _removed,
false, false, false);
}
...
}
Thanks
Jul 22 2011
I'm not sure about the issue, but just in case it's not known the newest DFL seems to be hosted on github: https://github.com/Rayerd/dfl It might have those issues fixed, unless this is where you've cloned from, in which case sorry for the noise.
Jul 22 2011
Jesse Phillips:It is not fixed there, it is missing a number of changes. This is one of them and I'm confused on since I thought override was supposed to, well override.
I think we are talking about two different things: overriding and overloading. Bye, bearophile
Jul 23 2011
Tyro[a.c.edwards]:[3] imagelist.d(22): Error: class dfl.imagelist.ImageList.ImageCollection use of dfl.imagelist.ImageList.ImageCollection.ListWrapArray!(Image,_images,_adding,_added,_blankListCallback,_removed,false,fal e,false).insert(int index, Image value) hidden by ImageCollection is deprecated Now I know I can bypass this with the -d switch but I'm more interested in fixing the problem than bypassing it.
There is a trick based on explicit alias to avoid those errors. I'd like the idea of using this alias to be present in that error message... Bye, bearophile
Jul 23 2011
On 7/23/2011 7:49 PM, bearophile wrote:Tyro[a.c.edwards]:[3] imagelist.d(22): Error: class dfl.imagelist.ImageList.ImageCollection use of dfl.imagelist.ImageList.ImageCollection.ListWrapArray!(Image,_images,_adding,_added,_blankListCallback,_removed,false,false,false).insert(int index, Image value) hidden by ImageCollection is deprecated Now I know I can bypass this with the -d switch but I'm more interested in fixing the problem than bypassing it.
There is a trick based on explicit alias to avoid those errors. I'd like the idea of using this alias to be present in that error message... Bye, bearophile
Please do share. I thought the concept explicit alias simply requires me to do his: alias ListWrapArray LWA; mixin LWA!(Image, _images, _adding, _added, _blankListCallback!(Image), _removed, false, false, false); This did not work... resulted in the same error. On closer look it seems the actual problem is not the template but the definition of "insert" therein. It is being hidden by the definition of insert in ImageCollection. ImageCollection definition: void insert(int index, Image img) { if(index >= _images.length) { add(img); } else { assert(0, "Must add images to the end of the image list"); } } ListWrapArray definition: void insert(int index, TValue value) { _insert(index, value); } In the end it turns out to be the same problem as one and two. Any suggestion on how to deal with these correctly? I can resolve this particular error by renaming the function to "Insert" in ImageCollection. But even though it appeases the compiler, is that the correct solution? Is there something else that I'm not taking into consideration? How do I fix the other two since there is no way to rename opApply and opCmp that I'm aware of? Thanks
Jul 23 2011
Tyro[a.c.edwards]:Please do share. I thought the concept explicit alias simply requires me to do his:
I meant this, but I don't know if this is enough to solve your problem: http://www.digitalmars.com/d/archives/digitalmars/D/learn/class_x_is_hidden_by_y_22131.html Bye, bearophile
Jul 24 2011
There is a trick based on explicit alias to avoid those errors. I'd like the idea of using this alias to be present in that error message...
http://d.puremagic.com/issues/show_bug.cgi?id=6373 Bye, bearophile
Jul 24 2011
On Sat, 23 Jul 2011 08:34:27 +0200, Andrej Mitrovic wrote:I'm not sure about the issue, but just in case it's not known the newest DFL seems to be hosted on github: https://github.com/Rayerd/dfl It might have those issues fixed, unless this is where you've cloned from, in which case sorry for the noise.
It is not fixed there, it is missing a number of changes. This is one of them and I'm confused on since I thought override was supposed to, well override.
Jul 23 2011
On Sat, 23 Jul 2011 10:51:35 -0400, bearophile wrote:Jesse Phillips:It is not fixed there, it is missing a number of changes. This is one of them and I'm confused on since I thought override was supposed to, well override.
I think we are talking about two different things: overriding and overloading. Bye, bearophile
Ok, I got it. The problem is not overriding ALL the opEquals functions in the child class. I.e. you must override all overloaded functions when overriding one function.
Jul 23 2011









bearophile <bearophileHUGS lycos.com> 