mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
type distinct: allow comparisons of type X<? extends Object> == X<array> (IDEA-135041)
This commit is contained in:
@@ -260,7 +260,11 @@ public class TypesDistinctProver {
|
||||
}
|
||||
else if (bound instanceof PsiWildcardType) {
|
||||
final PsiType boundBound = ((PsiWildcardType)bound).getBound();
|
||||
return boundBound != null && !boundBound.equals(type);
|
||||
if (boundBound != null && !boundBound.equals(type)) {
|
||||
final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(boundBound);
|
||||
return psiClass == null || !(((PsiWildcardType)bound).isExtends() && possibleClasses.contains(psiClass));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.io.Serializable;
|
||||
|
||||
class B {}
|
||||
abstract class A {
|
||||
abstract Class<?> get();
|
||||
abstract Class<? extends Object> get1();
|
||||
abstract Class<? super Object> get2();
|
||||
|
||||
abstract Class<? extends B> get3();
|
||||
abstract Class<? super B> get4();
|
||||
|
||||
abstract Class<? extends Serializable> get5();
|
||||
abstract Class<? super Serializable> get6();
|
||||
|
||||
{
|
||||
if (get() == byte[].class);
|
||||
if (get1() == byte[].class);
|
||||
if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? super java.lang.Object>>', 'java.lang.Class<byte[]>'">get2() == byte[].class</error>);
|
||||
if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? extends B>>', 'java.lang.Class<byte[]>'">get3() == byte[].class</error>);
|
||||
if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? super B>>', 'java.lang.Class<byte[]>'">get4() == byte[].class</error>);
|
||||
if (get5() == byte[].class);
|
||||
if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? super java.io.Serializable>>', 'java.lang.Class<byte[]>'">get6() == byte[].class</error>);
|
||||
}
|
||||
}
|
||||
@@ -450,6 +450,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testAssignabilityBetweenWildcardsAndArrays() throws Exception {
|
||||
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()));
|
||||
assertNotNull(collectionsClass);
|
||||
|
||||
Reference in New Issue
Block a user