mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
type parameter cannot be inherited with different arguments as well as any other class (IDEA-57324)
This commit is contained in:
+2
-3
@@ -415,7 +415,6 @@ public class GenericsHighlightUtil {
|
||||
}
|
||||
|
||||
public static HighlightInfo checkInterfaceMultipleInheritance(PsiClass aClass) {
|
||||
if (aClass instanceof PsiTypeParameter) return null;
|
||||
final PsiClassType[] types = aClass.getSuperTypes();
|
||||
if (types.length < 2) return null;
|
||||
Map<PsiClass, PsiSubstitutor> inheritedClasses = new HashMap<PsiClass, PsiSubstitutor>();
|
||||
@@ -442,8 +441,8 @@ public class GenericsHighlightUtil {
|
||||
if (inheritedSubstitutor != null) {
|
||||
final PsiTypeParameter[] typeParameters = superClass.getTypeParameters();
|
||||
for (PsiTypeParameter typeParameter : typeParameters) {
|
||||
PsiType type1 = inheritedSubstitutor.substitute(typeParameter);
|
||||
PsiType type2 = superTypeSubstitutor.substitute(typeParameter);
|
||||
PsiType type1 = GenericsUtil.eliminateWildcards(inheritedSubstitutor.substitute(typeParameter));
|
||||
PsiType type2 = GenericsUtil.eliminateWildcards(superTypeSubstitutor.substitute(typeParameter));
|
||||
|
||||
if (!Comparing.equal(type1, type2)) {
|
||||
String description = JavaErrorMessages.message("generics.cannot.be.inherited.with.different.type.arguments",
|
||||
|
||||
@@ -385,6 +385,8 @@ public class GenericsUtil {
|
||||
final PsiType bound = ((PsiWildcardType)type).getBound();
|
||||
return bound != null ? bound
|
||||
: ((PsiWildcardType)type).getExtendsBound();//object
|
||||
} else if (type instanceof PsiCapturedWildcardType && !eliminateInTypeArguments) {
|
||||
return eliminateWildcards(((PsiCapturedWildcardType)type).getWildcard(), eliminateInTypeArguments);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
interface IA<T> {}
|
||||
interface IB<T> extends IA<T> {}
|
||||
|
||||
class A {
|
||||
<<error descr="'IA' cannot be inherited with different type arguments: 'java.lang.Integer' and 'java.lang.String'"></error>T extends IA<Integer> & IB<String>> void foo(){}
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface IA1<T> {}
|
||||
interface IB1<T> extends IA1<T> {}
|
||||
|
||||
class A1 {
|
||||
<<error descr="'IA1' cannot be inherited with different type arguments: 'java.lang.Object' and 'capture<?>'"></error>T extends IA1<Object> & IB1<?>> void foo(){}
|
||||
}
|
||||
|
||||
interface IA2<T> {}
|
||||
interface IB2<T> extends IA2<T[]> {}
|
||||
|
||||
class A2 {
|
||||
<T extends IA2<Object[]> & IB2<?>> void foo(){}
|
||||
}
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA20573() throws Exception { doTest5(false);}
|
||||
public void testIDEA20244() throws Exception { doTest5(false);}
|
||||
public void testIDEA22005() throws Exception { doTest5(false);}
|
||||
public void testInheritedWithDifferentArgsInTypeParams() throws Exception { doTest5(false);}
|
||||
|
||||
public void testIDEA57877() throws Exception { doTest5(false);}
|
||||
public void testTypeParamsCyclicInference() throws Exception { doTest5(false);}
|
||||
|
||||
Reference in New Issue
Block a user