mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
check if super wildcard is within its bounds (IDEA-95065)
This commit is contained in:
@@ -262,7 +262,7 @@ public class GenericsHighlightUtil {
|
||||
final PsiClassType[] bounds = classParameter.getSuperTypes();
|
||||
for (PsiClassType type1 : bounds) {
|
||||
PsiType bound = substitutor.substitute(type1);
|
||||
if (checkNotInBounds(type, bound)) {
|
||||
if (!bound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) && checkNotInBounds(type, bound)) {
|
||||
PsiClass boundClass = bound instanceof PsiClassType ? ((PsiClassType)bound).resolve() : null;
|
||||
|
||||
@NonNls final String messageKey = boundClass == null || referenceClass == null || referenceClass.isInterface() == boundClass.isInterface()
|
||||
@@ -297,7 +297,7 @@ public class GenericsHighlightUtil {
|
||||
return checkExtendsWildcardCaptureFailure((PsiWildcardType)type, bound);
|
||||
}
|
||||
else if (((PsiWildcardType)type).isSuper()) {
|
||||
return checkNotAssignable(bound, ((PsiWildcardType)type).getSuperBound());
|
||||
return checkNotAssignable(bound, ((PsiWildcardType)type).getSuperBound(), false);
|
||||
}
|
||||
}
|
||||
else if (type instanceof PsiArrayType) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
class TopGene<T> {
|
||||
}
|
||||
|
||||
class MidRaw extends TopGene {
|
||||
}
|
||||
|
||||
class BottomGene<T> extends MidRaw {
|
||||
}
|
||||
|
||||
class GeneType<T extends TopGene<String>> {
|
||||
}
|
||||
|
||||
class GeneUser {
|
||||
public void success(GeneType<? extends BottomGene<String>> p) {
|
||||
}
|
||||
|
||||
public void fail(GeneType<<error descr="Type parameter '? super BottomGene<String>' is not within its bound; should extend 'TopGene<java.lang.String>'">? super BottomGene<String></error>> p) {
|
||||
}
|
||||
}
|
||||
@@ -198,6 +198,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testRawOnParameterized() throws Exception { doTest(false); }
|
||||
public void testFailedInferenceWithBoxing() throws Exception { doTest(false); }
|
||||
public void testFixedFailedInferenceWithBoxing() throws Exception { doTest17Incompatibility(false); }
|
||||
public void testSuperWildcardIsNotWithinItsBound() throws Exception { doTest17Incompatibility(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
Reference in New Issue
Block a user