From 1b745866b9f8220de1a4ff1ae1b40b0269f6e374 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 16 Nov 2012 14:22:44 +0100 Subject: [PATCH] check for specific return type should take substitutors into account (IDEA-95129) --- .../intellij/psi/impl/PsiSuperMethodImplUtil.java | 4 ++-- .../genericsHighlighting/SpecificReturnType.java | 13 +++++++++++++ .../daemon/GenericsHighlightingTest.java | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SpecificReturnType.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java index b84f064216b3..06d1226c6090 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java @@ -232,8 +232,8 @@ public class PsiSuperMethodImplUtil { } private static boolean isReturnTypeIsMoreSpecificThan(@NotNull HierarchicalMethodSignature thisSig, @NotNull HierarchicalMethodSignature thatSig) { - PsiType thisRet = thisSig.getMethod().getReturnType(); - PsiType thatRet = thatSig.getMethod().getReturnType(); + PsiType thisRet = thisSig.getSubstitutor().substitute(thisSig.getMethod().getReturnType()); + PsiType thatRet = thatSig.getSubstitutor().substitute(thatSig.getMethod().getReturnType()); return thatRet != null && thisRet != null && !thatRet.equals(thisRet) && TypeConversionUtil.isAssignable(thatRet, thisRet); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SpecificReturnType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SpecificReturnType.java new file mode 100644 index 000000000000..4fb890b3dfa5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/SpecificReturnType.java @@ -0,0 +1,13 @@ +abstract class Field { + public D getValue(){return null;} +} + +class LabelField extends Field { + public Object getValue() { return null; } +} +interface MyInterface { + D getValue(); +} + +class MyLabelField extends LabelField implements MyInterface { +} \ No newline at end of file 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 ca4bafc12a15..60683c9a9398 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -200,6 +200,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testFixedFailedInferenceWithBoxing() throws Exception { doTest17Incompatibility(false); } public void testInferenceWithBoxingCovariant() throws Exception { doTest17Incompatibility(false); } public void testSuperWildcardIsNotWithinItsBound() throws Exception { doTest17Incompatibility(false); } + public void testSpecificReturnType() throws Exception { doTest17Incompatibility(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));