diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java index f6553508a3d7..a7c3ca7b3ffd 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java @@ -23,7 +23,10 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; public class MethodSignatureUtil { @@ -320,16 +323,20 @@ public class MethodSignatureUtil { result = result.put(superTypeParameters[i], factory.createType(methodTypeParameter)); } + final PsiSubstitutor methodSubstitutor = methodSignature.getSubstitutor(); + //check bounds for (int i = 0; i < methodTypeParameters.length; i++) { PsiTypeParameter methodTypeParameter = methodTypeParameters[i]; PsiTypeParameter superTypeParameter = superTypeParameters[i]; final Set methodSupers = new HashSet(); - Collections.addAll(methodSupers, methodTypeParameter.getSuperTypes()); + for (PsiClassType methodSuper : methodTypeParameter.getSuperTypes()) { + methodSupers.add(methodSubstitutor.substitute(methodSuper)); + } final Set superSupers = new HashSet(); for (PsiClassType superSuper : superTypeParameter.getSuperTypes()) { - superSupers.add(result.substitute(superSuper)); + superSupers.add(methodSubstitutor.substitute(result.substitute(superSuper))); } methodSupers.remove(PsiType.getJavaLangObject(methodTypeParameter.getManager(), methodTypeParameter.getResolveScope())); superSupers.remove(PsiType.getJavaLangObject(superTypeParameter.getManager(), superTypeParameter.getResolveScope())); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UnifiedSubstitutorUpInTheHierarchy.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UnifiedSubstitutorUpInTheHierarchy.java new file mode 100644 index 000000000000..8ee848cca3e2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UnifiedSubstitutorUpInTheHierarchy.java @@ -0,0 +1,20 @@ +import java.io.Serializable; +import java.math.BigInteger; + +class C extends B { + @Override + public S save(S entity) { + return super.save(entity); + } +} + + +class B implements A { + public S save(S entity) { + return null; + } +} + +interface A { + S save(S var1); +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java index 21f506801484..d0eb309d8ae2 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java @@ -986,4 +986,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase { public void testUncheckedWarningsInsideIncorporationPhase() throws Exception { doTest(); } + + public void testUnifiedSubstitutorUpInTheHierarchy() throws Exception { + doTest(); + } }