mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
overload resolution: adapt return types before comparing (IDEA-177065)
This commit is contained in:
@@ -560,9 +560,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
return Specifics.FIRST;
|
||||
}
|
||||
|
||||
if (abstract1 && abstract2 && MethodSignatureUtil.areOverrideEquivalent(method1, method2)) {
|
||||
final PsiType returnType1 = method1.getReturnType();
|
||||
final PsiType returnType2 = method2.getReturnType();
|
||||
if (abstract1 && MethodSignatureUtil.areOverrideEquivalent(method1, method2)) { // abstract1 && abstract2
|
||||
final PsiType returnType1 = siteSubstitutor1.substitute(method1.getReturnType());
|
||||
final PsiType returnType2 = siteSubstitutor2.substitute(method2.getReturnType());
|
||||
if (returnType1 != null && returnType2 != null && returnType1.isAssignableFrom(returnType2)) {
|
||||
return Specifics.SECOND;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
interface A<T, ID> {
|
||||
Iterable<T> findAll(Iterable<ID> ids);
|
||||
}
|
||||
|
||||
interface B<T, ID> {
|
||||
List<T> findAll(Iterable<ID> ids);
|
||||
}
|
||||
|
||||
interface C<T> extends B<T, Integer>, A<T, Integer> {}
|
||||
|
||||
interface D extends C<String> {}
|
||||
|
||||
class Test {
|
||||
public void foo(D d, C<String> c) {
|
||||
List<Integer> ids = Collections.emptyList();
|
||||
List<String> strings = d.findAll(ids);
|
||||
List<String> strings1 = c.findAll(ids);
|
||||
}
|
||||
}
|
||||
@@ -260,6 +260,8 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testAdaptReturnTypesOfSiblingMethods() { doTest(false);}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user