capture wildcards in type casts (IDEA-101862; IDEA-97703)

This commit is contained in:
anna
2013-07-25 18:31:29 +02:00
parent 3165af31d5
commit b6884eab9f
3 changed files with 11 additions and 1 deletions
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source.tree.java;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.Constants;
import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.tree.IElementType;
@@ -46,7 +47,7 @@ public class PsiTypeCastExpressionImpl extends ExpressionPsiElement implements P
@Nullable public PsiType getType() {
final PsiTypeElement castType = getCastType();
if (castType == null) return null;
return castType.getType();
return PsiImplUtil.normalizeWildcardTypeByPosition(castType.getType(), this);
}
@Override
@@ -0,0 +1,8 @@
import java.util.Collection;
class Foo {
private void test() {
Object x = null;
((java.util.Collection<?>)x).add<error descr="'add(capture<?>)' in 'java.util.Collection' cannot be applied to '(java.lang.String)'">("")</error>;
}
}
@@ -304,6 +304,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA110869() { doTest5(false); }
public void testIDEA110947() { doTest5(false); }
public void testNoInferenceFromTypeCast() { doTest5(false); }
public void testCaptureWildcardsInTypeCasts() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));