mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
override clone specifics (IDEA-67754)
This commit is contained in:
+6
@@ -1094,6 +1094,12 @@ public class GenericsHighlightUtil {
|
||||
}
|
||||
try {
|
||||
MethodSignatureBackedByPsiMethod superMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
|
||||
if (superMethod != null && method.getContainingClass().isInterface() && "clone".equals(superMethod.getName())) {
|
||||
final PsiClass containingClass = superMethod.getMethod().getContainingClass();
|
||||
if (containingClass != null && CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
|
||||
superMethod = null;
|
||||
}
|
||||
}
|
||||
if (superMethod == null) {
|
||||
String description = JavaErrorMessages.message("method.does.not.override.super");
|
||||
HighlightInfo highlightInfo =
|
||||
|
||||
+8
@@ -146,6 +146,14 @@ public class HighlightMethodUtil {
|
||||
String detailMessage,
|
||||
PsiMethod methodToHighlight) {
|
||||
if (superReturnType == null) return null;
|
||||
if ("clone".equals(method.getName())) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
final PsiClass superContainingClass = superMethod.getContainingClass();
|
||||
if (containingClass != null && superContainingClass != null && containingClass.isInterface() && !superContainingClass.isInterface()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
PsiType substitutedSuperReturnType;
|
||||
final boolean isJdk15 = PsiUtil.isLanguageLevel5OrHigher(method);
|
||||
if (isJdk15 && !superMethodSignature.isRaw() && superMethodSignature.equals(methodSignature)) { //see 8.4.5
|
||||
|
||||
+13
-1
@@ -1,7 +1,19 @@
|
||||
interface MyCloneable {
|
||||
|
||||
//protected method from java.lang.Object is not implicitly declared in interface with no base interfaces
|
||||
<error descr="'clone()' in 'MyCloneable' clashes with 'clone()' in 'java.lang.Object'; attempting to use incompatible return type">int</error> clone();
|
||||
int clone();
|
||||
|
||||
<error descr="'toString()' in 'MyCloneable' clashes with 'toString()' in 'java.lang.Object'; attempting to use incompatible return type">int</error> toString();
|
||||
}
|
||||
|
||||
interface MyCloneable1 {
|
||||
<error descr="Method does not override method from its superclass">@Override</error>
|
||||
Object clone();
|
||||
}
|
||||
|
||||
class MyCloneable2 {
|
||||
@Override
|
||||
public Object clone() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
@@ -54,4 +54,5 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testJavacQuirks() { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
|
||||
public void testMethodReturnTypeSubstitutability() { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(true, false); }
|
||||
public void testIDEADEV11877() throws Exception { setLanguageLevel(LanguageLevel.JDK_1_6); doTest(false, false); }
|
||||
}
|
||||
|
||||
@@ -185,7 +185,6 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testCatchUnknownMethod() throws Exception { doTest(false, false); }
|
||||
public void testIDEADEV8822() throws Exception { doTest(false, false); }
|
||||
public void testIDEADEV9201() throws Exception { doTest(false, false); }
|
||||
public void testIDEADEV11877() throws Exception { doTest(false, false); }
|
||||
public void testIDEADEV25784() throws Exception { doTest(false, false); }
|
||||
public void testIDEADEV13249() throws Exception { doTest(false, false); }
|
||||
public void testIDEADEV11919() throws Exception { doTest(false, false); }
|
||||
|
||||
Reference in New Issue
Block a user