mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
method conflicts: prefer method with more specific return type (IDEA-67570)
This commit is contained in:
+2
-1
@@ -285,7 +285,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
final PsiSubstitutor cSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(class1, currentClass, PsiSubstitutor.EMPTY);
|
||||
if (MethodSignatureUtil.areSignaturesEqual(existingMethod.getSignature(eSubstitutor), method.getSignature(cSubstitutor))) {
|
||||
final PsiType returnType = eSubstitutor.substitute(existingMethod.getReturnType());
|
||||
if (!PsiUtil.captureToplevelWildcards(returnType, existingMethod).equals(returnType)) {
|
||||
final PsiType returnType1 = cSubstitutor.substitute(method.getReturnType());
|
||||
if (returnType != null && returnType1 != null && !returnType1.equals(returnType) && TypeConversionUtil.isAssignable(returnType, returnType1, false)) {
|
||||
conflicts.remove(existing);
|
||||
} else {
|
||||
conflicts.remove(i);
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
interface A1
|
||||
{
|
||||
String foo();
|
||||
}
|
||||
|
||||
interface B1
|
||||
{
|
||||
Object foo();
|
||||
}
|
||||
|
||||
class C1<T extends B1 & A1> {
|
||||
void bar(T x) {
|
||||
String foo = x.foo();
|
||||
}
|
||||
}
|
||||
|
||||
class C2<T extends A1 & B1> {
|
||||
void bar(T x) {
|
||||
String foo = x.foo();
|
||||
}
|
||||
}
|
||||
@@ -198,6 +198,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA67861() { doTest7Incompatibility(false); }
|
||||
public void testIDEA67597() { doTest5(false); }
|
||||
public void testIDEA57539() { doTest5(false); }
|
||||
public void testIDEA67570() { doTest5(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
|
||||
Reference in New Issue
Block a user