inference: do not infer from type cast (IDEA-111002)

This commit is contained in:
anna
2013-07-25 11:21:22 +02:00
parent 35ffbe1478
commit 3a4d70a453
3 changed files with 24 additions and 3 deletions
@@ -218,9 +218,6 @@ public class PsiTypesUtil {
return PsiType.BOOLEAN.getBoxedType(parent);
}
}
else if (parent instanceof PsiTypeCastExpression) {
return ((PsiTypeCastExpression)parent).getType();
}
else if (parent instanceof PsiReturnStatement) {
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class);
if (lambdaExpression != null) {
@@ -0,0 +1,23 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
interface A {}
interface B extends A {}
class Foo {
public <TA extends A> List<TA> getAs() {
return (List<TA>) getBs();
}
public <T extends B> List<T> getBs() {
return null;
}
void foo(Set<String> s) {}
{
foo(<error descr="Inconvertible types; cannot cast 'java.util.Set<java.lang.Object>' to 'java.util.Set<java.lang.String>'">(Set<String>)Collections.emptySet()</error>);
}
}
@@ -302,6 +302,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA57391() { doTest5(false); }
public void testIDEA110869() { doTest5(false); }
public void testIDEA110947() { doTest5(false); }
public void testNoInferenceFromTypeCast() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));