mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
red code is green: impossible to have 2 signatures with same signature and different primitive return types (IDEA-102866)
(cherry picked from commit c4093d0e8a1021f80fafb3c6b1fc35388da46ac6)
This commit is contained in:
+7
-4
@@ -1061,10 +1061,13 @@ public class HighlightMethodUtil {
|
||||
if (otherSuperReturnType == null || currentType == null || otherSuperReturnType.equals(currentType)) continue;
|
||||
|
||||
if (PsiUtil.isLanguageLevel5OrHigher(currentMethod)) {
|
||||
if (otherSuperReturnType.isAssignableFrom(currentType)) continue;
|
||||
if (currentType.isAssignableFrom(otherSuperReturnType)) {
|
||||
returnTypeSubstitutable = otherSuperSignature;
|
||||
continue;
|
||||
//http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.8 Example 8.1.5-3
|
||||
if (!(otherSuperReturnType instanceof PsiPrimitiveType || currentType instanceof PsiPrimitiveType)) {
|
||||
if (otherSuperReturnType.isAssignableFrom(currentType)) continue;
|
||||
if (currentType.isAssignableFrom(otherSuperReturnType)) {
|
||||
returnTypeSubstitutable = otherSuperSignature;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return createIncompatibleReturnTypeMessage(currentMethod, currentMethod, otherSuperMethod, false, otherSuperReturnType,
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
interface X4 { Integer m(); }
|
||||
interface Y4 { Number m(); }
|
||||
interface Z4 extends X4, Y4 {}
|
||||
|
||||
interface X1 { long m(); }
|
||||
interface Y1 { Number m(); }
|
||||
<error descr="'m()' in 'Y1' clashes with 'm()' in 'X1'; methods have unrelated return types">interface Z1 extends X1, Y1</error> {}
|
||||
|
||||
interface X2 { long m(); }
|
||||
interface Y2 { int m(); }
|
||||
<error descr="'m()' in 'X2' clashes with 'm()' in 'Y2'; methods have unrelated return types">interface Z2 extends X2, Y2</error> {}
|
||||
|
||||
interface X3 { String m(); }
|
||||
interface Y3 { Integer m(); }
|
||||
<error descr="'m()' in 'Y3' clashes with 'm()' in 'X3'; methods have unrelated return types">interface Z3 extends X3, Y3</error> {}
|
||||
|
||||
+1
@@ -58,4 +58,5 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testJavacQuirks() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
|
||||
public void testMethodReturnTypeSubstitutability() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user