capture getClass type inside expressions list (IDEA-57877)

This commit is contained in:
anna
2013-05-06 21:21:51 +02:00
parent 4886c2eda9
commit cf43a20b76
3 changed files with 11 additions and 1 deletions
@@ -177,7 +177,7 @@ public class PsiTypesUtil {
final PsiClassType classType = JavaPsiFacade.getInstance(project).getElementFactory()
.createType(javaLangClass, substitutor, languageLevel);
final PsiElement parent = call.getParent();
return parent instanceof PsiReferenceExpression && parent.getParent() instanceof PsiMethodCallExpression
return parent instanceof PsiReferenceExpression && parent.getParent() instanceof PsiMethodCallExpression || parent instanceof PsiExpressionList
? PsiUtil.captureToplevelWildcards(classType, methodExpression) : classType;
}
}
@@ -0,0 +1,8 @@
import java.util.*;
class Test {
{
Object obj = new Object();
<error descr="Incompatible types. Found: 'java.util.Set<java.lang.Class<capture<? extends java.lang.Object>>>', required: 'java.util.Set<java.lang.Class<?>>'">Set<Class<?>> types = Collections.singleton(obj.getClass());</error>
}
}
@@ -235,6 +235,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA20244() throws Exception { doTest5(false);}
public void testIDEA22005() throws Exception { doTest5(false);}
public void testIDEA57877() 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); }