mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
check all type parameters bounds (IDEA-109556)
This commit is contained in:
@@ -216,6 +216,7 @@ public class GenericsUtil {
|
||||
}
|
||||
|
||||
public static boolean isTypeArgumentsApplicable(PsiTypeParameter[] typeParams, PsiSubstitutor substitutor, final PsiElement context) {
|
||||
nextTypeParam:
|
||||
for (PsiTypeParameter typeParameter : typeParams) {
|
||||
PsiType substituted = substitutor.substitute(typeParameter);
|
||||
if (substituted == null) return true;
|
||||
@@ -225,7 +226,7 @@ public class GenericsUtil {
|
||||
for (PsiClassType type : extendsTypes) {
|
||||
PsiType extendsType = substitutor.substitute(type);
|
||||
if (extendsType.isAssignableFrom(substituted)) {
|
||||
return true;
|
||||
continue nextTypeParam;
|
||||
}
|
||||
}
|
||||
if (extendsTypes.length > 0) return false;
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Base { }
|
||||
class Extended extends Base {}
|
||||
|
||||
class Test<T extends Base> {
|
||||
<T extends Base, U extends T> void test(T x, Class<U> test) {}
|
||||
{
|
||||
<error descr="Inferred type 'Base' for type parameter 'U' is not within its bound; should extend 'Extended'">test(new Extended(), Base.class)</error>;
|
||||
}
|
||||
}
|
||||
@@ -306,6 +306,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testNoInferenceFromTypeCast() { doTest5(false); }
|
||||
public void testCaptureWildcardsInTypeCasts() { doTest5(false); }
|
||||
public void testIDEA111085() { doTest5(false); }
|
||||
public void testIDEA109556() { 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