generics: do not prefer interface over super class even if return type is more specific (IDEA-110568)

This commit is contained in:
anna
2013-07-16 12:30:04 +02:00
parent 968a43f445
commit 8a15ea45ab
3 changed files with 22 additions and 0 deletions
@@ -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);
@@ -0,0 +1,20 @@
import java.util.Collection;
public class IncorrectError extends NarrowClass {
public Collection<String> bar() {
return super.doStuff();
}
}
interface Interface {
Collection<String> doStuff();
}
class NarrowClass extends BaseClass implements Interface {
}
class BaseClass {
public Collection doStuff() {
return null;
}
}
@@ -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);}