Hello @core-libs-dev <[email protected]>,

In case you are not aware, one unfortunate wart in the Collections library
is that, if you have a List<Integer>, then it is very easy for Overload
selection to pick the wrong method when you do List.remove(Object) vs
List.remove(int). This is because, if you have pass in an Integer, overload
selection calls List.remove(Object), but if you pass in an int, overload
selection calls List.remove(int).

One surefire way to make sure you don't get hurt by this is to make an
explicit cast to (int) or (Integer), allowing you to communicate intent
about which method you want. However, you then get a warning about
redundant cast.

Sure, we could add @SuppressWarnings everywhere that we do this, but that's
not ideal. Would it make sense to special case the warning to skip over
this case?

Thank you for your time and consideration.
David Alayachew

Reply via email to