diff --git a/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java b/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java index 0dfd7488c21b..19d1eb9bfa08 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/ConflictsUtil.java @@ -75,7 +75,7 @@ public class ConflictsUtil { } } - if (method != null && method != refactoredMethod) { + if (method != null && method != refactoredMethod && !isStaticInterfaceMethods(aClass, refactoredMethod, method)) { if (aClass.equals(method.getContainingClass())) { final String classDescr = aClass instanceof PsiAnonymousClass ? RefactoringBundle.message("current.class") : @@ -116,6 +116,11 @@ public class ConflictsUtil { } } + private static boolean isStaticInterfaceMethods(PsiClass aClass, PsiMethod refactoredMethod, PsiMethod method) { + return aClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC) && + refactoredMethod != null && refactoredMethod.hasModifierProperty(PsiModifier.STATIC); + } + private static String getMethodPrototypeString(final PsiMethod prototype) { return PsiFormatUtil.formatMethod( prototype, diff --git a/java/java-tests/testData/refactoring/renameCollisions/RenameNoStaticOverridingInInterfaces.java b/java/java-tests/testData/refactoring/renameCollisions/RenameNoStaticOverridingInInterfaces.java new file mode 100644 index 000000000000..1ed4b3daab46 --- /dev/null +++ b/java/java-tests/testData/refactoring/renameCollisions/RenameNoStaticOverridingInInterfaces.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface A +{ + static void foo(){} +} +interface B extends A +{ + static int bar(){ return 1; } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/renameCollisions/RenameNoStaticOverridingInInterfaces.java.after b/java/java-tests/testData/refactoring/renameCollisions/RenameNoStaticOverridingInInterfaces.java.after new file mode 100644 index 000000000000..2398a2ef819e --- /dev/null +++ b/java/java-tests/testData/refactoring/renameCollisions/RenameNoStaticOverridingInInterfaces.java.after @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface A +{ + static void foo(){} +} +interface B extends A +{ + static int foo(){ return 1; } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/RenameCollisionsTest.java b/java/java-tests/testSrc/com/intellij/refactoring/RenameCollisionsTest.java index e09c448319a9..4fc42408bab3 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/RenameCollisionsTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/RenameCollisionsTest.java @@ -197,6 +197,10 @@ public class RenameCollisionsTest extends LightRefactoringTestCase { doTest("foo2"); } + public void testRenameNoStaticOverridingInInterfaces() throws Exception { + doTest("foo"); + } + public void testRenameTypeParameterToExistingClassName() throws Exception { doTest("P"); }