diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java index f74d883834cf..d003e4aa7013 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java @@ -302,6 +302,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ final PsiType returnType = eSubstitutor.substitute(existingMethod.getReturnType()); final PsiType returnType1 = cSubstitutor.substitute(method.getReturnType()); if (returnType != null && returnType1 != null && !returnType1.equals(returnType) && TypeConversionUtil.isAssignable(returnType, returnType1, false)) { + if (class1.isInterface() && !existingClass.isInterface()) continue; conflicts.remove(existing); } else { conflicts.remove(i); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java new file mode 100644 index 000000000000..ed9eedd55331 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA110568.java @@ -0,0 +1,20 @@ +import java.util.Collection; + +public class IncorrectError extends NarrowClass { + public Collection bar() { + return super.doStuff(); + } +} + +interface Interface { + Collection doStuff(); +} + +class NarrowClass extends BaseClass implements Interface { +} + +class BaseClass { + public Collection doStuff() { + return null; + } +} 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 ec241b5e8e42..ed1769bb46dc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -244,6 +244,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIllegalForwardReferenceInTypeParameterDefinition() throws Exception { doTest5(false);} public void testIDEA57877() throws Exception { doTest5(false);} + public void testIDEA110568() throws Exception { doTest5(false);} public void testTypeParamsCyclicInference() throws Exception { doTest5(false);} public void testCaptureTopLevelWildcardsForConditionalExpression() throws Exception { doTest5(false);} public void testGenericsOverrideMethodInRawInheritor() throws Exception { doTest5(false);}