I have a Java overloading issue that I cannot understand.
The code is as follows:
private void f(Object o) {
}
private void f(Collection c) {
}
private <T> T dummy() {
return null;
}
private void g() {
f(dummy());
}
Now, dummy() returns an object of an undefined type so erasure should lead to a type of Object. However, the invocation f(dummy()) actually calls f(Collection) and not f(Object). Why is this the case?