mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
old inference: choose child type between types in subtypes constraint (IDEA-118536)
This commit is contained in:
+6
-1
@@ -286,7 +286,8 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
|
||||
Pair<PsiType, ConstraintType> otherConstraint =
|
||||
inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy);
|
||||
if (otherConstraint != null) {
|
||||
if (otherConstraint.getSecond() == ConstraintType.EQUALS || otherConstraint.getSecond() == ConstraintType.SUPERTYPE) {
|
||||
if (otherConstraint.getSecond() == ConstraintType.EQUALS || otherConstraint.getSecond() == ConstraintType.SUPERTYPE ||
|
||||
compareSubtypes(constraint.getFirst(), otherConstraint.getFirst())) {
|
||||
constraint = otherConstraint;
|
||||
}
|
||||
}
|
||||
@@ -307,6 +308,10 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper {
|
||||
return partialSubstitutor;
|
||||
}
|
||||
|
||||
private static boolean compareSubtypes(final PsiType type, final PsiType parentType) {
|
||||
return type != null && parentType != null && TypeConversionUtil.isAssignable(type, parentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import java.util.Comparator;
|
||||
|
||||
class MyTest {
|
||||
void foo(final Ordering<Comparable> natural){
|
||||
compound(natural);
|
||||
}
|
||||
<U extends String> Ordering<U> compound(Comparator<? super U> secondaryComparator) { return null; }
|
||||
}
|
||||
abstract class Ordering <T> implements Comparator<T> {}
|
||||
|
||||
@@ -353,6 +353,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA123509() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA125031() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA24479() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA118536() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
Reference in New Issue
Block a user