clashing return type of overriding methods: fix unchecked override comparison (IDEA-166355)

This commit is contained in:
Anna.Kozlova
2017-01-10 15:20:38 +01:00
parent 5880b3ac4f
commit 977c4cc924
3 changed files with 19 additions and 1 deletions

View File

@@ -1350,7 +1350,7 @@ public class HighlightMethodUtil {
return null;
}
}
if (otherSuperMethod.getTypeParameters().length > 0 && JavaGenericsUtil.isRawToGeneric(curType, otherReturnType)) return null;
if (otherSuperMethod.getTypeParameters().length > 0 && JavaGenericsUtil.isRawToGeneric(otherReturnType, curType)) return null;
}
return createIncompatibleReturnTypeMessage(otherSuperMethod, currentMethod, curType, otherReturnType,
JavaErrorMessages.message("unrelated.overriding.methods.return.types"), TextRange.EMPTY_RANGE);

View File

@@ -0,0 +1,14 @@
interface X {}
interface Y extends X {}
interface A {
<T extends X> T get();
}
interface B extends A {
@Override
Y get();
}
interface C extends B {}

View File

@@ -614,4 +614,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testErasureOfMethodCallExpressionTypeIfItDoesntDependOnGenericsParameter() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
public void testUncheckedConversionInReturnType() throws Exception {
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
}