You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Organize Imports should be smarter about single-letter types #1438
When there's an unresolved single-letter type usage in the code, doing Organize Imports should not blindly import a type it finds
Environment
Operating System: Windows 10
JDK version: 14
Visual Studio Code version: 1.45.0
Java extension version: 0.61.0
Steps To Reproduce
do Organize Imports on the code below, while there's a single type T available for import (in my case it was inside Apache POI, but you could just create a trivial T.java file
the actual issue here is that I forgot to specify the type variable T. Ideally, the extension would give a single error saying exactly that. If that's not feasible, it should at least ask confirmation before importing single-letter types, even if there's only a single one available: the chances that the user actually wants to import such a type are much smaller than the chance that there's an error w.r.t. type variables
Parameterized types are not limited to single-letter symbols. For example you can have a class like this:
public class MyClaz<TA> {
public void print(Comparable<TA> bar, Map<Integer, TA> whatever) {
}
}
Secondly, the current behavior matches that of eclipse. If you don't parameterize your class, any reasonable implementation would assume a class within your project or your classpath might be your parameter type.
Activity
robstryker commentedon Oct 29, 2026
Parameterized types are not limited to single-letter symbols. For example you can have a class like this:
Secondly, the current behavior matches that of eclipse. If you don't parameterize your class, any reasonable implementation would assume a class within your project or your classpath might be your parameter type.
Closing, works as intended.