IDEA-115368 Smart type completion popup offers Object.class ahead of local Class<?> variable

This commit is contained in:
peter
2013-11-03 20:54:48 +01:00
parent 60d1e15e46
commit ad779bf2f9
3 changed files with 19 additions and 1 deletions
@@ -331,7 +331,11 @@ public class JavaCompletionSorting {
if (type instanceof PsiClassType) {
final PsiClass psiClass = ((PsiClassType)type).resolve();
if (psiClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(psiClass.getQualifiedName())) {
return GenericsUtil.eliminateWildcards(type);
PsiClassType erased = (PsiClassType)GenericsUtil.eliminateWildcards(type);
PsiType[] parameters = erased.getParameters();
if (parameters.length == 1 && !parameters[0].equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
return erased;
}
}
}
return type;
@@ -0,0 +1,11 @@
class Foo {
static void bar(Class<?> type) {
}
public static void main(String[] args) {
Class<?> type;
bar(<caret>);
}
}
@@ -317,6 +317,9 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
public void testGetWildcardLogger() {
checkPreferredItems 0, 'Foo.class', 'forName'
}
public void testPreferLocalWildcardClassOverObject() {
checkPreferredItems 0, 'type', 'Object.class'
}
@Override
protected String getBasePath() {