unrelated defaults: ignore type parameters check for abstract methods only, leave as is for defaults

This commit is contained in:
Anna Kozlova
2016-03-11 10:02:54 +01:00
parent 4edf0fac79
commit ea84b25cc5
2 changed files with 6 additions and 3 deletions

View File

@@ -442,7 +442,6 @@ public class GenericsHighlightUtil {
static HighlightInfo checkUnrelatedDefaultMethods(@NotNull PsiClass aClass,
@NotNull PsiIdentifier classIdentifier) {
if (aClass instanceof PsiTypeParameter) return null;
final Map<MethodSignature, Set<PsiMethod>> overrideEquivalent =
new THashMap<MethodSignature, Set<PsiMethod>>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
PsiClass[] supers = aClass.getSupers();
@@ -501,7 +500,8 @@ public class GenericsHighlightUtil {
final PsiMethod unrelatedMethod = astracts != null ? astracts.get(0) : defaults.get(1);
final PsiClass unrelatedMethodContainingClass = unrelatedMethod.getContainingClass();
if (unrelatedMethodContainingClass == null) continue;
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT) && astracts != null && unrelatedMethodContainingClass.isInterface()) {
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !(aClass instanceof PsiTypeParameter)
&& astracts != null && unrelatedMethodContainingClass.isInterface()) {
if (defaultMethodContainingClass.isInheritor(unrelatedMethodContainingClass, true) &&
MethodSignatureUtil.isSubsignature(unrelatedMethod.getSignature(TypeConversionUtil.getSuperClassSubstitutor(unrelatedMethodContainingClass, defaultMethodContainingClass, PsiSubstitutor.EMPTY)),
defaultMethod.getSignature(PsiSubstitutor.EMPTY))) {

View File

@@ -7,8 +7,11 @@ interface B extends A {
}
interface C extends A {}
interface D extends C {}
interface E {
default void f() {}
}
class U {
<T extends B & C> void m (){}
<T extends B & D> void m1(){}
<<error descr="T inherits abstract and default for f() from types E and B">T</error> extends B & E> void m2(){}
}