mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
correct super method hierarchy for multiple inheritance
This commit is contained in:
@@ -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) {
|
||||
|
||||
+16
@@ -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>
|
||||
}
|
||||
}
|
||||
+14
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user