mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 05:51:25 +07:00
intersect thrown types when implementing 2 interfaces with same method signature (IDEA-82426)
This commit is contained in:
@@ -282,12 +282,14 @@ public class GenerateMembersUtil {
|
||||
final List<PsiClassType> thrownTypes = ExceptionUtil.collectSubstituted(collisionResolvedSubstitutor, sourceMethod.getThrowsList().getReferencedTypes(),
|
||||
scope);
|
||||
if (target instanceof PsiClass) {
|
||||
final PsiClass[] supers = ((PsiClass)target).getSupers();
|
||||
for (PsiClass aSuper : supers) {
|
||||
final PsiMethod psiMethod = aSuper.findMethodBySignature(sourceMethod, true);
|
||||
final PsiMethod[] methods = ((PsiClass)target).findMethodsBySignature(sourceMethod, true);
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
if (psiMethod != null && psiMethod != sourceMethod) {
|
||||
PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)target, PsiSubstitutor.EMPTY);
|
||||
ExceptionUtil.retainExceptions(thrownTypes, ExceptionUtil.collectSubstituted(superClassSubstitutor, psiMethod.getThrowsList().getReferencedTypes(), scope));
|
||||
PsiClass aSuper = psiMethod.getContainingClass();
|
||||
if (aSuper != null && aSuper != target) {
|
||||
PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)target, PsiSubstitutor.EMPTY);
|
||||
ExceptionUtil.retainExceptions(thrownTypes, ExceptionUtil.collectSubstituted(superClassSubstitutor, psiMethod.getThrowsList().getReferencedTypes(), scope));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
interface A {
|
||||
void a() throws java.io.IOException;
|
||||
}
|
||||
|
||||
interface B {
|
||||
void a() throws InstantiationException;
|
||||
}
|
||||
|
||||
interface C extends A, B {}
|
||||
|
||||
class D implements C {
|
||||
@Override
|
||||
public void a() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
interface A {
|
||||
void a() throws java.io.IOException;
|
||||
}
|
||||
|
||||
interface B {
|
||||
void a() throws InstantiationException;
|
||||
}
|
||||
|
||||
interface C extends A, B {}
|
||||
|
||||
class D implements C {
|
||||
<caret>
|
||||
}
|
||||
@@ -39,6 +39,7 @@ class OverrideImplementTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testSkipUnknownAnnotations() { doTest(true) }
|
||||
public void testMultipleInheritedThrows() { doTest(false) }
|
||||
public void testOverrideInInterface() { doTest(false) }
|
||||
public void testMultipleInheritanceWithThrowables() { doTest(true) }
|
||||
|
||||
public void testImplementInInterface() {
|
||||
myFixture.addClass """\
|
||||
|
||||
Reference in New Issue
Block a user