mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
do not check within bounds for super wildcards
This commit is contained in:
+14
-10
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user