capture top level wildcards when choosing conditional expression type (~IDEA-16723)

This commit is contained in:
anna
2013-05-07 11:42:14 +02:00
parent 9bd45c2ab0
commit fe9777e840
5 changed files with 19 additions and 1 deletions

View File

@@ -97,7 +97,8 @@ public class PsiConditionalExpressionImpl extends ExpressionPsiElement implement
if (type2 == null) return null;
}
return GenericsUtil.getLeastUpperBound(type1, type2, getManager());
final PsiType leastUpperBound = GenericsUtil.getLeastUpperBound(type1, type2, getManager());
return leastUpperBound != null ? PsiUtil.captureToplevelWildcards(leastUpperBound, this) : null;
}
@Override

View File

@@ -0,0 +1,6 @@
import java.util.*;
class Bug {
void foo(Double d) {
<error descr="Incompatible types. Found: 'java.util.List<java.lang.Class<capture<? extends java.lang.Object>>>', required: 'java.util.List<java.lang.Class<?>>'">List<Class<?>> list = Arrays.asList(d == null ? Object.class : d.getClass());</error>
}
}

View File

@@ -0,0 +1,6 @@
import java.util.*;
class Bug {
void foo(Double d) {
List<Class<?>> list = Arrays.<Class<?>>asList(d == null ? Object.class : d.getClass());
}
}

View File

@@ -236,6 +236,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA22005() throws Exception { doTest5(false);}
public void testIDEA57877() throws Exception { doTest5(false);}
public void testCaptureTopLevelWildcardsForConditionalExpression() throws Exception { doTest5(false);}
public void testIDEA27185(){ doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
public void testIDEA67571(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }

View File

@@ -29,4 +29,8 @@ public class RedundantTypeArgsInspectionTest extends JavaCodeInsightFixtureTestC
public void testReturnPrimitiveTypes() throws Throwable { // javac non-boxing: IDEA-53984
doTest();
}
public void testConditionalExpression() throws Throwable { // javac non-boxing: IDEA-53984
doTest();
}
}