provably distinct (IDEA-67682)

This commit is contained in:
anna
2013-07-18 16:52:55 +02:00
parent 9e83fd241c
commit 4c0d630919
3 changed files with 18 additions and 2 deletions

View File

@@ -36,8 +36,8 @@ public class TypesDistinctProver {
}
protected static boolean provablyDistinct(PsiType type1, PsiType type2, int level) {
if (type1 instanceof PsiClassType && ((PsiClassType)type1).resolve() instanceof PsiTypeParameter) return false;
if (type2 instanceof PsiClassType && ((PsiClassType)type2).resolve() instanceof PsiTypeParameter) return false;
if (type1 instanceof PsiClassType && ((PsiClassType)type1).resolve() instanceof PsiTypeParameter && level < 2) return false;
if (type2 instanceof PsiClassType && ((PsiClassType)type2).resolve() instanceof PsiTypeParameter && level < 2) return false;
if (type1 instanceof PsiWildcardType) {
if (type2 instanceof PsiWildcardType) {
return provablyDistinct((PsiWildcardType)type1, (PsiWildcardType)type2);

View File

@@ -0,0 +1,15 @@
import java.util.List;
abstract class B {
<T> void foo(List<List<String>[]> x) {
Object y1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.util.List<java.lang.String>[]>' to 'java.util.List<java.util.List<T>[]>'">(List<List<T>[]>)x</error>;
}
<T> void foo1(List<List<List<String>>[]> x) {
Object y1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.util.List<java.util.List<java.lang.String>>[]>' to 'java.util.List<java.util.List<java.util.List<T>>[]>'">(List<List<List<T>>[]>)x</error>;
}
<T> void foo2(List<String[]> x) {
Object y1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.lang.String[]>' to 'java.util.List<T[]>'">(List<T[]>)x</error>;
}
}

View File

@@ -298,6 +298,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA57325() { doTest5(false); }
public void testIDEA67835() { doTest5(false); }
public void testIDEA67744() { doTest5(false); }
public void testIDEA67682() { doTest5(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));