Bug 322177 - Organize Imports removes nested class import used in generic of top level class
Summary: Organize Imports removes nested class import used in generic of top level class
Status: VERIFIED DUPLICATE of bug 294057
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-09 14:51 EDT by Jan Bernitt CLA
Modified: 2010-08-26 10:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Bernitt CLA 2010-08-09 14:51:28 EDT
Build Identifier: M20100211-1343

If I use a inner type as the type parameter of a generic interface implemented by the top level type contains the inner one, I need to import that inner class or I got compile errors. But this import is removed by organize imports all the time.

Example:

class TopLevelType implements SomeInterfaceType<InnerType> {

  static class InnerType {
     ...
  }

  ...
}

Reproducible: Always

Steps to Reproduce:
1. See example Class in Details.
Comment 1 Srikanth Sankaran CLA 2010-08-09 17:33:48 EDT
Can you please include more detailed examples showing
how the code looks before and after the organize
import operation ? Thanks.
Comment 2 Jan Bernitt CLA 2010-08-09 18:26:08 EDT
Before:

import some.package.TopLevelType.InnerType;

class TopLevelType implements SomeInterfaceType<InnerType> {

  static class InnerType {
     ...
  }

  ...
}

After:

Same but without the import statement. This is necessary since I use the inner type already as generic type argument. 

I also have to say that there is another issue with inner types and organize imports that might be connected to this one:  

If you use for example the InnerType from the example above in another type (file) and you don't want to refer to it through TopLevelType.InnerType you'll have to do the import on your own (no automatic import by auto-complete as normal). If than organize imports is performed this import is removed sometimes. I think this happens when the InnerType is contained in a file that is in the same package as the file where I want to use it again.
Comment 3 Srikanth Sankaran CLA 2010-08-09 18:47:12 EDT
Us lazy folks prefer a self contained piece of code that
could be pasted into package explorer as it is, such as:

// -------------------------------8<-----------------------------
package some.pakage;
import some.pakage.TopLevelType.InnerType;

class TopLevelType implements SomeInterfaceType<InnerType> {
  static class InnerType {
  }
}
interface SomeInterfaceType<T> {}
// -------------------------------8<-----------------------------

This problem does not show up on HEAD (3.7 stream).
I'll dig up the duplicate number shortly.
Comment 4 Srikanth Sankaran CLA 2010-08-09 18:58:16 EDT
Most likely a duplicate of bug 294057 which
got fixed in 3.6 M6.

Jan, are you in a position to check against 3.6 ?

Can I also request you to test the "another issue with inner types"
that you refer to against 3.6 and report if it persists ?

Thanks in advance.
Comment 5 Srikanth Sankaran CLA 2010-08-09 22:43:41 EDT
(In reply to comment #4)
> Most likely a duplicate of bug 294057 which
> got fixed in 3.6 M6.
> 
> Jan, are you in a position to check against 3.6 ?

I have verified that this is a duplicate of bug 294057
by checking that this problem shows up on 3.6 M5 and
does not show up on 3.6 M6.

Closing as duplicate of bug 294057

Jan, for the other issues you refer to, please check if
they exist on 3.6 and if they do, raise separate defects
with suitable test cases, TIA.

*** This bug has been marked as a duplicate of bug 294057 ***
Comment 6 Frederic Fusier CLA 2010-08-26 10:36:31 EDT
Verified for 3.6.1