mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inference: do not infer from type cast (IDEA-111002)
This commit is contained in:
@@ -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) {
|
||||
|
||||
+23
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user