Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 339173

Summary: [quick fix] "Infer Generic type arguments" quick fix is not useful
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Deepak Azad CLA 2011-03-08 03:24:17 EST
----------------------------------------------------------------------------
package p;

import java.util.Arrays;
import java.util.Comparator;

class A {
	void bar(Integer a[], int b[]) {
		Arrays.sort(a, new Comparator() { // ctrl+1 on this line

			@Override
			public int compare(Object object1, Object object2) {
				// TODO Auto-generated method stub
				return 0;
			}
		});
	}
}
----------------------------------------------------------------------------
- Place caret in "new Comparator()"
  OR
  Select "Type safety: The expression of type new Comparator(){} needs unchecked conversion to conform to Comparator<? super Integer>" in problems view
- Crtl+1
- Select "Infer Generic type arguments"
=> the refactoring does not change anything

The same can also be seen in org.eclipse.jdt.internal.ui.dialogs.TypeInfoViewer line 716, where the refactoring results in some changes but on other lines in the file.
Comment 1 Deepak Azad CLA 2011-03-08 03:24:47 EST
Build id is I20110307-2110.
Comment 2 Markus Keller CLA 2011-03-09 12:06:49 EST
Unfortunately, it's very hard to find out when the Infer Generic Type Arguments refactoring will not be able to fix the problems, so I think we have to live with that.

See bug 338404 for a solution tailored to this specific problem.