good code red: do not create ? super Object constraint as nothing would match (IDEA-77991)

This commit is contained in:
anna
2012-04-03 19:19:43 +02:00
parent b053dbdfdf
commit 6719c86450
3 changed files with 17 additions and 1 deletions
@@ -462,10 +462,11 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
JavaResolveResult paramResult = ((PsiClassType)param).resolveGenerics();
PsiClass paramClass = (PsiClass)paramResult.getElement();
if (typeParam == paramClass) {
final PsiClass psiClass = PsiUtil.resolveClassInType(arg);
if (arg == null ||
arg.getDeepComponentType() instanceof PsiPrimitiveType ||
arg instanceof PsiIntersectionType ||
PsiUtil.resolveClassInType(arg) != null) {
(psiClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName()))) {
PsiType bound = intersectAllExtends(typeParam, arg);
return new Pair<PsiType, ConstraintType>(bound, ConstraintType.SUPERTYPE);
}
@@ -0,0 +1,14 @@
class Test {
static {
Class<Test> testClass = get(Test.class);
foo(testClass);
}
static <E> Class<E> get(Class<? super E> value) {
return null;
}
static <E> E foo(Class<? super E> value) {
return null;
}
}
@@ -120,6 +120,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testTypeParameterBoundVisibilityJdk14() throws Exception { doTest(false);}
public void testUncheckedWarningsLevel6() throws Exception { doTest(true);}
public void testIDEA77991() throws Exception { doTest(false);}
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));