I find myself frequently making the following error.
public class Foo{
Bar bar;
public void doSomething(){
Bar bar = makeNewBar();
// bla bla
}
}
where the error is that I want to set Foo's bar, not a local Bar. I.e, I should say bar = makeNewBar()
, not Bar bar = makeNewBar()
. Is there a compiler warning flag or something that can detect "namespace collisions" like this? If not, what's a good way to avoid this (short of not making the error, which is obviously the best option =p)?