mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
type param bound check fixed (IDEA-110869)
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ public class GenericsHighlightUtil {
|
||||
for (PsiClassType type : extendsTypes) {
|
||||
PsiType extendsType = substitutor.substitute(type);
|
||||
if (substituted instanceof PsiWildcardType) {
|
||||
if (!((PsiWildcardType)substituted).isExtends()) {
|
||||
if (((PsiWildcardType)substituted).isSuper()) {
|
||||
continue;
|
||||
}
|
||||
final PsiType extendsBound = ((PsiWildcardType)substituted).getExtendsBound();
|
||||
|
||||
+5
-2
@@ -902,8 +902,11 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
PsiType substituted = argResult.getSubstitutor().substitute(typeParameter);
|
||||
if (substituted != null) {
|
||||
Pair<PsiType, ConstraintType> res = getSubstitutionForTypeParameterInner(
|
||||
superSubstitutor.substitute(typeParameter), substituted, patternType, ConstraintType.EQUALS, depth);
|
||||
if (res != null) return res;
|
||||
superSubstitutor.substitute(typeParameter), substituted, patternType, ConstraintType.EQUALS, depth + 1);
|
||||
if (res != null) {
|
||||
if (res == FAILED_INFERENCE) continue;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
}
|
||||
|
||||
abstract class B {
|
||||
public <T extends A> T getA(Class<T> aClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo(Class<?> aClass) {
|
||||
A a = <error descr="Inferred type '?' for type parameter 'T' is not within its bound; should extend 'A'">getA(aClass)</error>;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -2,12 +2,15 @@ import java.util.List;
|
||||
|
||||
abstract class B {
|
||||
abstract <T> T[] foo(List<? super List<T>> x);
|
||||
abstract <T> T foo0(List<? super List<T>> x);
|
||||
abstract <T> T[] foo1(List<? extends List<T>> x);
|
||||
abstract <T> T[] foo2(List<List<? super List<T>>> x);
|
||||
|
||||
void bar(List<List<?>> x, List<List<List<?>>> y){
|
||||
foo(x) [0] = "";
|
||||
foo1<error descr="'foo1(java.util.List<? extends java.util.List<T>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
|
||||
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<T>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
|
||||
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<java.lang.Object>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
|
||||
|
||||
String s = foo0(x);
|
||||
}
|
||||
}
|
||||
@@ -300,6 +300,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA67744() { doTest5(false); }
|
||||
public void testIDEA67682() { doTest5(false); }
|
||||
public void testIDEA57391() { doTest5(false); }
|
||||
public void testIDEA110869() { doTest5(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
Reference in New Issue
Block a user