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

Bug 349403

Summary: [quick fix] Unnecessary imports being added for member types
Product: [Eclipse Project] JDT Reporter: Raksha Vasisht <raksha.vasisht>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, Olivier_Thomann, srikanth_sankaran
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Raksha Vasisht CLA 2011-06-15 03:17:02 EDT
BETA_JAVA7


public class test2 {
	
	 class C {}
	 interface I {}

	 public class X<T extends C & I> {
	     X() {}
	     X f = new X<>();
	 }
}

ctrl +1 on X  -> 'Change type to 'X<? extends C>' and 'Add type arguments to X'
add unnecessary imports.

I'll take a look.
Comment 1 Raksha Vasisht CLA 2011-06-20 13:47:50 EDT
Moving to Core..Seems like a problem in 

org.eclipse.jdt.core.dom.rewrite.ImportRewrite.findInImports(String, String, int)

The secondary type(s) are not recognised as known in the context, hence unnecessary imports are added.
Comment 2 Olivier Thomann CLA 2011-06-20 13:56:07 EDT
These are member types, not secondary types. Secondary types are top level types that are defined as non public types into a compilation unit with another public type.
I'll investigate. Organize import properly removes these unused imports.
Comment 3 Raksha Vasisht CLA 2011-06-20 16:51:54 EDT
(In reply to comment #2)
> These are member types, not secondary types. Secondary types are top level
> types that are defined as non public types into a compilation unit with another
> public type.
Oops, sorry I meant to write member types!
Comment 4 Markus Keller CLA 2011-07-10 19:22:11 EDT
Also happens without diamond if you use "new X<CI>()" with
class CI extends C implements I { }
Comment 5 Eclipse Genie CLA 2019-07-30 17:52:07 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.