inline: use wildcard bound to avoid ? in top level type element (IDEA-144883)

This commit is contained in:
Anna Kozlova
2015-09-08 15:10:00 +03:00
parent 76081b5b78
commit 8356d38604
4 changed files with 39 additions and 0 deletions
@@ -343,6 +343,12 @@ public class InlineUtil {
PsiElement resolved = resolveResult.getElement();
if (resolved instanceof PsiTypeParameter) {
PsiType newType = resolveResult.getSubstitutor().putAll(substitutor).substitute((PsiTypeParameter)resolved);
if (newType instanceof PsiCapturedWildcardType) {
newType = ((PsiCapturedWildcardType)newType).getUpperBound();
}
if (newType instanceof PsiWildcardType) {
newType = ((PsiWildcardType)newType).getBound();
}
if (newType == null) {
newType = PsiType.getJavaLangObject(resolved.getManager(), resolved.getResolveScope());
}
@@ -0,0 +1,16 @@
interface Pair<A extends String> {
A get();
}
class B {
<V extends String> void f(Pair<V> p) {
V v = p.get();
}
{
Pair<?> p = null;
<caret>f(p);
}
}
@@ -0,0 +1,13 @@
interface Pair<A extends String> {
A get();
}
class B {
{
Pair<?> p = null;
String v = p.get();
}
}
@@ -185,6 +185,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
doTest();
}
public void testSubstitutionForWildcards() throws Exception {
doTest();
}
public void testParamNameConflictsWithLocalVar() throws Exception {
doTest();
}