mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
bound promotion for super wildcard (? super A (bound extends A) == A)
This commit is contained in:
@@ -389,6 +389,16 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (substituted instanceof PsiWildcardType && ((PsiWildcardType)substituted).isSuper()) {
|
||||
final PsiType erasure = TypeConversionUtil.erasure(((PsiWildcardType)substituted).getBound());
|
||||
if (erasure != null) {
|
||||
final PsiType[] boundTypes = typeParameter.getExtendsListTypes();
|
||||
for (PsiType boundType : boundTypes) {
|
||||
if (TypeConversionUtil.isAssignable(boundType, erasure) || TypeConversionUtil.isAssignable(erasure, boundType)) {
|
||||
return boundType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (captureContext != null) {
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import java.io.Serializable;
|
||||
|
||||
interface Parametrized<T extends Number> {}
|
||||
|
||||
class Bug1<T extends Serializable>{
|
||||
<I extends Number> Parametrized<I> foo(Parametrized<I> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bug1(Parametrized<? super T> param) {
|
||||
foo(param);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Bug2<T extends Integer>{
|
||||
<I extends Number> Parametrized<I> foo(Parametrized<I> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bug1(Parametrized<? super T> param) {
|
||||
foo(param);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Test {
|
||||
interface Parametrized<T extends Serializable> {}
|
||||
|
||||
class Bug1<T extends Serializable>{
|
||||
<I extends Number> Parametrized<I> foo(Parametrized<I> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bug1(Parametrized<? super T> param) {
|
||||
<error descr="Inferred type 'java.io.Serializable' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Bug2<T extends Integer>{
|
||||
<I extends Number> Parametrized<I> foo(Parametrized<I> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bug1(Parametrized<? super T> param) {
|
||||
<error descr="Inferred type 'java.io.Serializable' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -338,6 +338,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA118527() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA120153() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
|
||||
public void testSuperWildcardWithBoundPromotion() { 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