Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349403 - [quick fix] Unnecessary imports being added for member types
Summary: [quick fix] Unnecessary imports being added for member types
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-15 03:17 EDT by Raksha Vasisht CLA
Modified: 2019-07-30 17:52 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.