mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 13:20:53 +07:00
don't loose type parameter bounds during super substitution (IDEA-175471)
This commit is contained in:
@@ -265,8 +265,8 @@ public class GenericsHighlightUtil {
|
||||
}
|
||||
|
||||
final PsiClassType[] bounds = classParameter.getSuperTypes();
|
||||
for (PsiClassType type1 : bounds) {
|
||||
PsiType bound = substitutor.substitute(type1);
|
||||
for (PsiType bound : bounds) {
|
||||
bound = substitutor.substitute(bound);
|
||||
if (!bound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) && GenericsUtil.checkNotInBounds(type, bound, referenceParameterList)) {
|
||||
PsiClass boundClass = bound instanceof PsiClassType ? ((PsiClassType)bound).resolve() : null;
|
||||
|
||||
|
||||
@@ -129,7 +129,12 @@ public class JavaClassSupersImpl extends JavaClassSupers {
|
||||
Map<PsiTypeParameter, PsiType> innerMap = inner.getSubstitutionMap();
|
||||
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(onClass)) {
|
||||
if (outerMap.containsKey(parameter) || innerMap.containsKey(parameter)) {
|
||||
answer = answer.put(parameter, outer.substitute(inner.substitute(parameter)));
|
||||
PsiType innerType = inner.substitute(parameter);
|
||||
PsiClass paramCandidate = PsiCapturedWildcardType.isCapture() ? PsiUtil.resolveClassInClassTypeOnly(innerType) : null;
|
||||
PsiType targetType = paramCandidate instanceof PsiTypeParameter && paramCandidate != parameter
|
||||
? outer.substituteWithBoundsPromotion((PsiTypeParameter)paramCandidate)
|
||||
: outer.substitute(innerType);
|
||||
answer = answer.put(parameter, targetType);
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class P<T, Self extends P<T, Self>> { }
|
||||
|
||||
class MM<T, H extends P<T, H>> {
|
||||
H last;
|
||||
|
||||
void m(final Function<P<T, ?>, P<T, ?>> function) {
|
||||
generate(last, function);
|
||||
}
|
||||
public static <E> void generate(E first, Function<? super E, ? extends E> generator) { }
|
||||
|
||||
}
|
||||
interface Function<Param, Result> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
interface Child<T extends Serializable> extends List<T> {
|
||||
default void m(List<Child<?>> l) {
|
||||
List<? extends List<? extends Serializable>> ll = l;
|
||||
}
|
||||
}
|
||||
@@ -425,4 +425,5 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testUncheckedWarningWhenCastingFromCapturedWildcard() { doTest8Incompatibility(true); }
|
||||
public void testEnclosingRefInTopLevelClassExtendingInnerWhichExtendsItsOuter() { doTest8Incompatibility(true); }
|
||||
public void testGenericThrowTypes() { doTest5(false); }
|
||||
public void testRecursiveParamBoundsWhenSuperSubstitution() { doTest6(false); }
|
||||
}
|
||||
@@ -1032,4 +1032,5 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testBridgeMethodOverriding() { doTest(); }
|
||||
public void testNestedWildcardsWithImplicitBounds() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user