diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java new file mode 100644 index 000000000000..78333b113ec6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodSignatureEquality.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2010 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. + */ +import java.io.*; +class Test { + interface InterfA { + void foo(T x); + + void foo(T x); + } + + abstract class A { + abstract & Serializable> void foo(T x, A y); + + abstract > void foo(T x, A y); + } + + /* abstract class B { + abstract & Serializable> void foo(T x, B y); + + abstract > void foo(T x, B y); + } + + + abstract class C { + abstract & Serializable> void foo(T x, C y); + + abstract > void foo(T x, C y); + }*/ + + abstract class D { + abstract > void foo(T x, D y); + + abstract > void foo(T x, D y); + } + + + interface IA {} + interface IB {} + void testExtendsOrder() { + class E { + void foo(E x) {} + void foo(E x) {} + } + } + + abstract class F { + abstract void foo(F y); + + abstract void foo(F y); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 2b091ef594a1..96ef628df38b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -98,6 +98,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testSuperMethodCallWithErasure() throws Exception { doTest(false); } public void testWildcardCastConversion() throws Exception { doTest(false); } public void testTypeWithinItsWildcardBound() throws Exception { doTest(false); } + public void testMethodSignatureEquality() throws Exception { doTest(false); } public void testJavaUtilCollections() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); diff --git a/java/openapi/src/com/intellij/psi/util/MethodSignatureUtil.java b/java/openapi/src/com/intellij/psi/util/MethodSignatureUtil.java index a8cc1102dfcf..73318fb601a5 100644 --- a/java/openapi/src/com/intellij/psi/util/MethodSignatureUtil.java +++ b/java/openapi/src/com/intellij/psi/util/MethodSignatureUtil.java @@ -23,6 +23,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -226,14 +227,16 @@ public class MethodSignatureUtil { for (int i = 0; i < methoTypeParameters.length; i++) { PsiTypeParameter methoTypeParameter = methoTypeParameters[i]; PsiTypeParameter superTypeParameter = superTypeParameters[i]; - final PsiClassType[] methoSupers = methoTypeParameter.getSuperTypes(); - final PsiClassType[] superSupers = superTypeParameter.getSuperTypes(); - if (methoSupers.length != superSupers.length) return null; - for (int j = 0; j < methoSupers.length; j++) { - PsiType type1 = methodSubstitutor.substitute(methoSupers[j]); - PsiType type2 = methodSubstitutor.substitute(PsiUtil.captureToplevelWildcards(result.substitute(superSupers[j]), methoTypeParameter)); - if (!type1.equals(type2)) return null; + final Set methoSupers = new HashSet(); + for (PsiClassType methoSuper : methoTypeParameter.getSuperTypes()) { + methoSupers.add(methodSubstitutor.substitute(methoSuper)); } + + final Set superSupers = new HashSet(); + for (PsiClassType superSuper : superTypeParameter.getSuperTypes()) { + superSupers.add(methodSubstitutor.substitute(PsiUtil.captureToplevelWildcards(result.substitute(superSuper), methoTypeParameter))); + } + if (!methoSupers.equals(superSupers)) return null; } return result; }