correct super method hierarchy for multiple inheritance

This commit is contained in:
anna
2013-01-08 13:13:49 +01:00
parent 79e0bf7d4c
commit 5f7a5c98d7
4 changed files with 35 additions and 4 deletions
@@ -215,15 +215,15 @@ public class PsiSuperMethodImplUtil {
LOG.assertTrue(copy.getMethod().isValid());
map.put(signature, copy);
}
else if (isSuperMethod(aClass, existing, hierarchicalMethodSignature)) {
mergeSupers(existing, hierarchicalMethodSignature);
}
else if (isReturnTypeIsMoreSpecificThan(hierarchicalMethodSignature, existing) && isSuperMethod(aClass, hierarchicalMethodSignature, existing)) {
HierarchicalMethodSignatureImpl newSuper = copy(hierarchicalMethodSignature);
mergeSupers(newSuper, existing);
LOG.assertTrue(newSuper.getMethod().isValid());
map.put(signature, newSuper);
}
else if (isSuperMethod(aClass, existing, hierarchicalMethodSignature)) {
mergeSupers(existing, hierarchicalMethodSignature);
}
// just drop an invalid method declaration there - to highlight accordingly
else if (!result.containsKey(signature)) {
LOG.assertTrue(hierarchicalMethodSignature.getMethod().isValid());
@@ -234,7 +234,7 @@ public class PsiSuperMethodImplUtil {
private static boolean isReturnTypeIsMoreSpecificThan(@NotNull HierarchicalMethodSignature thisSig, @NotNull HierarchicalMethodSignature thatSig) {
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);
return thatRet != null && thisRet != null && !thatRet.equals(thisRet) && TypeConversionUtil.isAssignable(thatRet, thisRet, false);
}
private static void mergeSupers(final HierarchicalMethodSignatureImpl existing, final HierarchicalMethodSignature superSignature) {
@@ -0,0 +1,16 @@
interface A
{
abstract String foo();
}
interface B
{
abstract Object foo();
}
class C implements A, B
{
public String foo() {
<selection>return null; //To change body of implemented methods use File | Settings | File Templates.</selection>
}
}
@@ -0,0 +1,14 @@
interface A
{
abstract String foo();
}
interface B
{
abstract Object foo();
}
class C implements A, B
{
<caret>
}
@@ -62,6 +62,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
public void testOnTheLineWithExistingExpression() { doTest(false); }
public void testSimplifyObjectWildcard() { doTest(false); }
public void testErasureWildcard() { doTest(false); }
public void testMultipleInterfaceInheritance() { doTest(false); }
public void testImplementExtensionMethods() { doTest8(false, true); }
public void testDoNotImplementExtensionMethods() { doTest8(false, true); }