mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
type arguments distinct checker: do not distinguish wildcards with array bounds from arrays with corresponding bounds (IDEA-134944)
This commit is contained in:
@@ -259,6 +259,9 @@ public class TypesDistinctProver {
|
||||
else if (bound instanceof PsiWildcardType) {
|
||||
final PsiType boundBound = ((PsiWildcardType)bound).getBound();
|
||||
if (boundBound != null && !boundBound.equals(type)) {
|
||||
if (boundBound instanceof PsiArrayType && !((PsiWildcardType)bound).isSuper()) {
|
||||
return proveArrayTypeDistinct(type, boundBound);
|
||||
}
|
||||
final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(boundBound);
|
||||
if (psiClass == null) {
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public static <T> void fooBar(final Class<?> aClass,
|
||||
final Class<? super Number[]> aSuperClass,
|
||||
final Class<? extends Number[]> anExtendsClass) {
|
||||
Class<T[]> klazz = (Class<T[]>) aClass;
|
||||
klazz = <error descr="Inconvertible types; cannot cast 'java.lang.Class<capture<? super java.lang.Number[]>>' to 'java.lang.Class<T[]>'">(Class<T[]>) aSuperClass</error>;
|
||||
klazz = (Class<T[]>) anExtendsClass;
|
||||
}
|
||||
}
|
||||
@@ -536,6 +536,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testProvablyDistinctForWildcardsWithArrayBounds() 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