expected variable type: make type denotable (IDEA-136958)

This commit is contained in:
Anna Kozlova
2015-03-25 20:04:56 +01:00
parent 1636ae40dd
commit 21fd57c89f
4 changed files with 30 additions and 1 deletions
@@ -422,7 +422,7 @@ public class GenericsUtil {
}
else {
final PsiType accepted = typeArgument.accept(this);
if (typeArgument instanceof PsiIntersectionType) {
if (typeArgument instanceof PsiIntersectionType && !(accepted instanceof PsiWildcardType)) {
toPut = PsiWildcardType.createExtends(typeParameter.getManager(), accepted);
}
else {
@@ -0,0 +1,13 @@
import java.util.Arrays;
import java.util.List;
class Test {
interface I {}
enum X implements I {a}
enum Y implements I {a}
{
List<? extends Enum<? extends Enum<? extends Enum<?>>>> l = Arrays.asList(X.a, Y.a);
}
}
@@ -0,0 +1,12 @@
import java.util.Arrays;
class Test {
interface I {}
enum X implements I {a}
enum Y implements I {a}
{
<selection>Arrays.asList(X.a, Y.a)</selection>;
}
}
@@ -449,6 +449,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("l", false, false, false, "I<java.lang.String>", true));
}
public void testIntersectionWildcardExpectedType() {
doTest(new MockIntroduceVariableHandler("l", false, false, false, "java.util.List<? extends java.lang.Enum<? extends java.lang.Enum<? extends java.lang.Enum<?>>>>", true));
}
public void testMethodRefNotInContextInferredFilterWithNonAcceptableSince() {
//though test extracts method reference which is not suppose to appear with language level 1.7
//@since 1.8 in Consumer prevent it to appear at first position