return type equivalence: compare supers with current method (IDEA-147335)

This commit is contained in:
Anna Kozlova
2016-01-07 20:14:48 +01:00
parent 3793131697
commit c16e402bed
3 changed files with 19 additions and 4 deletions
@@ -1302,9 +1302,8 @@ public class HighlightMethodUtil {
}
if (currentMethod.getTypeParameters().length > 0 && JavaGenericsUtil.isRawToGeneric(currentType, otherSuperReturnType)) continue;
}
return createIncompatibleReturnTypeMessage(currentMethod, otherSuperMethod, otherSuperReturnType,
currentType, JavaErrorMessages.message("unrelated.overriding.methods.return.types"),
TextRange.EMPTY_RANGE);
return createIncompatibleReturnTypeMessage(otherSuperMethod, currentMethod, currentType, otherSuperReturnType,
JavaErrorMessages.message("unrelated.overriding.methods.return.types"), TextRange.EMPTY_RANGE);
}
return null;
}
@@ -1327,7 +1326,7 @@ public class HighlightMethodUtil {
HighlightInfo highlightInfo;
if (allAbstracts) {
superSignatures = new ArrayList<HierarchicalMethodSignature>(superSignatures);
superSignatures.add(signature);
superSignatures.add(0, signature);
highlightInfo = checkInterfaceInheritedMethodsReturnTypes(superSignatures, languageLevel);
}
else {
@@ -0,0 +1,12 @@
abstract class Child implements Human {}
interface Human extends Mother, Father {
Human me();
}
interface Father {
Father me();
}
interface Mother {
Mother me();
}
@@ -555,6 +555,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testReturnTypeOverrideEquivalenceWithTypeHierarchy() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testLeastUpperBoundWithRecursiveTypes() throws Exception {
final PsiManager manager = getPsiManager();
final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());