delegate: don't copy override as it would be added explicitly (IDEA-178893)

This commit is contained in:
Anna Kozlova
2017-09-13 13:26:46 +03:00
parent a64a674ebd
commit d031850315
4 changed files with 34 additions and 1 deletions

View File

@@ -163,7 +163,8 @@ public class GenerateDelegateHandler implements LanguageCodeInsightActionHandler
stmt = (PsiStatement)CodeStyleManager.getInstance(psiManager.getProject()).reformat(stmt);
method.getBody().add(stmt);
GenerateMembersUtil.copyAnnotations(methodCandidate.getElement().getModifierList(), method.getModifierList(), SuppressWarnings.class.getName());
GenerateMembersUtil.copyAnnotations(methodCandidate.getElement().getModifierList(), method.getModifierList(),
SuppressWarnings.class.getName(), Override.class.getName());
if (isMethodStatic || modifierList != null && modifierList.hasModifierProperty(PsiModifier.STATIC)) {
PsiUtil.setModifierProperty(method, PsiModifier.STATIC, true);

View File

@@ -0,0 +1,17 @@
interface I {
void foo();
}
class A implements I {
@Override
public void foo() {
}
}
class B {
A a;
public void foo() {
a.foo();
}
}

View File

@@ -0,0 +1,14 @@
interface I {
void foo();
}
class A implements I {
@Override
public void foo() {
}
}
class B {
A a;
<caret>
}

View File

@@ -58,6 +58,7 @@ public class DelegateMethodsTest extends LightCodeInsightTestCase {
public void testMultipleOverrideAnnotations() { doTest(); }
public void testStripSuppressWarningsAnnotation() { doTest(); }
public void testDoNotOverrideFinal() { doTest(); }
public void testEnsureCorrectOverride() { doTest(); }
public void testAllowDelegateToFinal() { doTest(); }
public void testDelegateWithSubstitutionOverrides() { doTest(); }
public void testDelegateWithSubstitutionNoOverrides() { doTest(); }