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

Bug 434604

Summary: [infer type arguments] Does not infer type argument for field in a generic class
Product: [Eclipse Project] JDT Reporter: Martin Mathew <manju656>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.8.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Martin Mathew CLA 2014-05-11 22:51:54 EDT
Consider the below code snippet: 

import java.util.Set;

class A<T> {
	Set s;
	void foo(){
		s.add("String");
	}
}

On hovering over the warning we get 2 Quick Fix options
[1] Add type arguments to 'Set'
	On selecting this option, code will be refactored to Set<?> s;, which results in compiler error
[2] Infer Generic Type Arguments,
	On selecting this refactoring, the preview shows no source code changes. If the second check box is left un-checked, then same result as [1].

If class A is not generic, then the quick fix works properly refactoring the code to Set<String> s;.  Also the issue seems to happen only for fields, but not for method parameter or local variable.
Comment 1 Eclipse Genie CLA 2019-09-30 17:08:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.