I have following code
public class GenericTest {
    public <T extends Number> void someMethod(){
        Map<T, String> map = new HashMap<>();
        someLegacyMethod(map.keySet());  // COMPILER ERROR
    }
    public String someLegacyMethod(Set<Number> nums){
        //some logic
        return "";
    }
}
I was expecting that someLegacyMethod can be called as is as T is of type Number. But compiler gives me an error.
The method someLegacyMethod(Set<Number>) in the type GenericTest is not applicable for the arguments (Set<T>)
So either I have to modify the legacy method to take it typed argument, or cast the method parameter everytime I call the method. Why doesn't the above code work? And is there any other cleaner way to make this work?
 
     
     
     
     
    