mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
type distinction: remove non-symmetrie for type param bounds (IDEA-150724)
This commit is contained in:
@@ -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;
|
||||
|
||||
+11
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user