make variable type A<? super B&C> denotable (IDEA-57518; IDEA-57273)

This commit is contained in:
Anna Kozlova
2015-12-09 22:03:56 +01:00
parent 1149601c1b
commit 9697949fe1
6 changed files with 53 additions and 0 deletions
@@ -320,6 +320,11 @@ public class GenericsUtil {
final PsiType bound = wildcardType.getBound();
PsiManager manager = wildcardType.getManager();
if (bound != null) {
if (wildcardType.isSuper() && bound instanceof PsiIntersectionType) {
return PsiWildcardType.createUnbounded(manager);
}
final PsiType acceptedBound = bound.accept(this);
if (acceptedBound instanceof PsiWildcardType) {
if (((PsiWildcardType)acceptedBound).isExtends() != wildcardType.isExtends()) return PsiWildcardType.createUnbounded(manager);
@@ -0,0 +1,9 @@
abstract class A<S> {
abstract <T> T foo(T x, T y);
{
A<? extends A<? super A<Object>>> a = null;
A<? extends A<? super A<String>>> b = null;
A<? extends A<?>> m = foo(a, b);
}
}
@@ -0,0 +1,9 @@
abstract class A<S> {
abstract <T> T foo(T x, T y);
{
A<? extends A<? super A<Object>>> a = null;
A<? extends A<? super A<String>>> b = null;
<selection>foo(a, b)</selection>;
}
}
@@ -0,0 +1,11 @@
interface I<T>{}
interface A extends I<I<? super String>> {}
interface B extends I<I<? super Integer>> {}
abstract class X {
abstract <T> T foo(T x, T y);
void bar(A x, B y){
I<? extends I<?>> m = foo(x, y);
}
}
@@ -0,0 +1,11 @@
interface I<T>{}
interface A extends I<I<? super String>> {}
interface B extends I<I<? super Integer>> {}
abstract class X {
abstract <T> T foo(T x, T y);
void bar(A x, B y){
<selection>foo(x, y)</selection>;
}
}
@@ -500,6 +500,14 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "Foo.I"));
}
public void testDenotableType1() {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "A<? extends A<?>>"));
}
public void testDenotableType2() {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "I<? extends I<?>>"));
}
public void testReturnNonExportedArray() {
doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") {
@Override