do not check within bounds for super wildcards

This commit is contained in:
anna
2013-02-15 16:28:13 +01:00
parent 1b51773d43
commit e120d0af1f
3 changed files with 32 additions and 10 deletions
@@ -68,17 +68,21 @@ public class GenericsHighlightUtil {
PsiClassType[] extendsTypes = typeParameter.getExtendsListTypes();
for (PsiClassType type : extendsTypes) {
PsiType extendsType = substitutor.substitute(type);
if (substituted instanceof PsiWildcardType &&
TypeConversionUtil.erasure(extendsType).equals(TypeConversionUtil.erasure(((PsiWildcardType)substituted).getExtendsBound()))) {
PsiType extendsBound = ((PsiWildcardType)substituted).getExtendsBound();
if (extendsBound instanceof PsiClassType) {
PsiType[] parameters = ((PsiClassType)extendsBound).getParameters();
if (parameters.length == 1) {
PsiType argType = parameters[0];
if (argType instanceof PsiCapturedWildcardType) {
argType = ((PsiCapturedWildcardType)argType).getWildcard();
if (substituted instanceof PsiWildcardType) {
if (!((PsiWildcardType)substituted).isExtends()) {
continue;
}
final PsiType extendsBound = ((PsiWildcardType)substituted).getExtendsBound();
if (TypeConversionUtil.erasure(extendsType).equals(TypeConversionUtil.erasure(extendsBound))) {
if (extendsBound instanceof PsiClassType) {
PsiType[] parameters = ((PsiClassType)extendsBound).getParameters();
if (parameters.length == 1) {
PsiType argType = parameters[0];
if (argType instanceof PsiCapturedWildcardType) {
argType = ((PsiCapturedWildcardType)argType).getWildcard();
}
if (argType instanceof PsiWildcardType && !((PsiWildcardType)argType).isBounded()) continue;
}
if (argType instanceof PsiWildcardType && !((PsiWildcardType)argType).isBounded()) continue;
}
}
}
@@ -0,0 +1,15 @@
import java.util.Comparator;
public class Main2 {
static class OfRef<T> {
public OfRef() {
this((Comparator<? super T>) naturalOrder());
}
public OfRef(Comparator<? super T> comparator) {
}
static <K extends Comparable<? super K>> Comparator<K> naturalOrder() {
return null;
}
}
}
@@ -204,6 +204,9 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA99061() { doTest5(false); }
public void testIDEA99347() { doTest5(false); }
public void testIDEA86875() { doTest5(false); }
public void testDisableWithinBoundsCheckForSuperWildcards() {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));