type distinction: remove non-symmetrie for type param bounds (IDEA-150724)

This commit is contained in:
Anna Kozlova
2016-01-27 13:57:06 +03:00
parent 64585129f6
commit ec89fa2295
3 changed files with 15 additions and 8 deletions
@@ -402,14 +402,6 @@ public class TypeConversionUtil {
PsiType typeArg2 = substitutor2.substitute(typeParameter);
if (typeArg1 == null || typeArg2 == null) return true;
if (TypesDistinctProver.provablyDistinct(typeArg1, typeArg2, level)) return false;
final PsiClass class1 = PsiUtil.resolveClassInType(typeArg1);
if (class1 instanceof PsiTypeParameter) {
for (PsiType type : class1.getExtendsListTypes()) {
type = substitutor1.substitute(type);
if (TypesDistinctProver.provablyDistinct(type, typeArg2) && !isAssignable(type, typeArg2)) return false;
}
}
}
return true;
@@ -0,0 +1,11 @@
interface A<<warning descr="Type parameter 'K' is never used">K</warning>> {}
abstract class B implements A<B> {}
abstract class C<V extends A<V>> {
void m(V v){
C<B> c = <warning descr="Unchecked cast: 'C<V>' to 'C<B>'">(C<B>) this</warning>;
System.out.println(c);
System.out.println(v);
}
}
@@ -567,6 +567,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testRecursiveTypesTypeArgumentDistinction() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, true);
}
public void testLeastUpperBoundWithRecursiveTypes() throws Exception {
final PsiManager manager = getPsiManager();
final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());