Community
Participate
Working Groups
I20040914-gtk I would like to see a refactoring / quick assist "Loosen Type Constraint" or "Widen Type Constraint" that helps to widen a generic type bound in a method signature as far as possible. This would be similar to the current "Use supertype where possible" refactoring. Consider the following examples: public void write(List<? super Number> list) { list.add(new Integer(1)); list.add(new Integer(2)); list.add(new Integer(3)); } "Loosen" should propose to widen the type bound to <? super Integer>, since that is all that is needed by the current implementation. public void read(List<? extends Integer> list) { Number num= list.get(0); System.out.println(obj); } "Loosen" should propose to widen the type bound to <? extends Number>, since that is all that is needed by the current implementation.
Fair request.