substitute with bounds promotion: don't wrap wildcards

This commit is contained in:
Anna Kozlova
2016-02-01 15:56:54 +03:00
parent e6357ca1dd
commit 7bbd70e695
3 changed files with 19 additions and 0 deletions

View File

@@ -110,6 +110,9 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
if (substituted instanceof PsiWildcardType && !((PsiWildcardType)substituted).isSuper()) {
final PsiWildcardType wildcardType = (PsiWildcardType)substituted;
final PsiType glb = PsiCapturedWildcardType.captureUpperBound(typeParameter, wildcardType, this);
if (glb instanceof PsiWildcardType) {
return glb;
}
if (glb != null ) {
return glb instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)glb).getWildcard()
: PsiWildcardType.createExtends(typeParameter.getManager(), glb);

View File

@@ -0,0 +1,12 @@
class C<M extends L, L> {}
class B<K extends C<?, ?>>{
K get() {
return null;
}
{
C c = get();
}
}

View File

@@ -593,4 +593,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testReturnTypeSubstitutableForSameOverrideEquivalentMethods() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testCaptureConversionWithWildcardBounds() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
}