substitute with bounds promotion: don't open captured wildcard for supers (IDEA-155370)

This commit is contained in:
Anna Kozlova
2016-07-04 10:21:00 +03:00
parent 48954bbd29
commit 33273be517
3 changed files with 27 additions and 14 deletions
@@ -117,22 +117,14 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
if (glb instanceof PsiWildcardType) {
return glb;
}
if (glb != null ) {
return glb instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)glb).getWildcard()
: PsiWildcardType.createExtends(typeParameter.getManager(), glb);
if (glb instanceof PsiCapturedWildcardType) {
PsiWildcardType wildcard = ((PsiCapturedWildcardType)glb).getWildcard();
if (!wildcard.isSuper()) return wildcard;
}
/*
if (glb instanceof PsiCapturedWildcardType) {
PsiWildcardType wildcard = ((PsiCapturedWildcardType)glb).getWildcard();
if (!wildcard.isSuper()) return wildcard;
}
if (glb != null ) {
return PsiWildcardType.createExtends(typeParameter.getManager(), glb);
}
*/
if (glb != null) {
return PsiWildcardType.createExtends(typeParameter.getManager(), glb);
}
}
return substituted;
}
@@ -0,0 +1,13 @@
import a.Provider;
public abstract class Test<T> {
private void configure(Provider<T> provider,
Test<? super T> sBind,
Test<? extends T> eBind) {
sBind.toProvider(provider);
eBind.toProvider<error descr="Cannot resolve method 'toProvider(a.Provider<T>)'">(provider)</error><EOLError descr="';' expected"></EOLError>
}
abstract void toProvider(Provider<? extends T> var1);
abstract void toProvider(b.Provider<? extends T> var1);
}
@@ -47,6 +47,14 @@ public class LightAdvHighlightingFixtureTest extends LightCodeInsightFixtureTest
assertNull(ReferencesSearch.search(aClass).findFirst());
}
public void testBoundsPromotionWithCapturedWildcards() throws Exception {
myFixture.addClass("package a; public interface Provider<A> {}");
myFixture.addClass("package b; public interface Provider<B> {}");
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting();
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/advFixture";