mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
check to prevent contradicted intersection type (IDEA-67600)
This commit is contained in:
@@ -371,7 +371,12 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
!TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(TypeConversionUtil.erasure(originalBound)) &&
|
||||
!TypeConversionUtil.erasure(substitutedBoundType).isAssignableFrom(originalBound)) { //erasure is essential to avoid infinite recursion
|
||||
if (wildcardType.isExtends()) {
|
||||
final PsiType glb = GenericsUtil.getGreatestLowerBound(wildcardType.getBound(), substitutedBoundType);
|
||||
final PsiType bound = wildcardType.getBound();
|
||||
if (bound instanceof PsiArrayType && substitutedBoundType instanceof PsiArrayType &&
|
||||
!bound.isAssignableFrom(substitutedBoundType) && !substitutedBoundType.isAssignableFrom(bound)) {
|
||||
continue;
|
||||
}
|
||||
final PsiType glb = GenericsUtil.getGreatestLowerBound(bound, substitutedBoundType);
|
||||
if (glb != null) {
|
||||
substituted = PsiWildcardType.createExtends(manager, glb);
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
abstract class A<T, S extends T>
|
||||
{
|
||||
abstract S bar();
|
||||
void foo(A<Runnable[], ? extends Cloneable[]> a){
|
||||
<error descr="Incompatible types. Found: 'java.lang.Cloneable[]', required: 'java.lang.Runnable[]'">Runnable[] x = a.bar();</error>
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AB<T, S extends T>
|
||||
{
|
||||
abstract S bar();
|
||||
void foo(AB<Runnable, ? extends Cloneable> a){
|
||||
Runnable x = a.bar();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AC<T, S>
|
||||
{
|
||||
abstract S bar();
|
||||
void foo(AC<Runnable[], ? extends Cloneable[]> a){
|
||||
<error descr="Incompatible types. Found: 'java.lang.Cloneable[]', required: 'java.lang.Runnable[]'">Runnable[] x = a.bar();</error>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +367,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA125800() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA125816() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA57338() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
|
||||
public void testIDEA67600() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
//jdk should propagate LL 1.4 but actually it provides LL 1.7?!
|
||||
public void testCastObjectToIntJdk14() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_4, false); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user