mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inference: allow capture during intersection type construction (IDEA-173900)
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.RecursionGuard;
|
||||
import com.intellij.openapi.util.RecursionManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -83,13 +82,17 @@ public class PsiCapturedWildcardType extends PsiType.Stub {
|
||||
glb = substitutedBoundType;
|
||||
}
|
||||
else {
|
||||
glb = GenericsUtil.getGreatestLowerBound(glb, substitutedBoundType);
|
||||
glb = getGreatestLowerBound(glb, substitutedBoundType, wildcardType);
|
||||
}
|
||||
}
|
||||
|
||||
return glb;
|
||||
}
|
||||
|
||||
private static PsiType getGreatestLowerBound(PsiType glb, PsiType bound, Object guardObject) {
|
||||
return guard.doPreventingRecursion(guardObject, true, () -> GenericsUtil.getGreatestLowerBound(glb, bound));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof PsiCapturedWildcardType)) {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PsiIntersectionType extends PsiType.Stub {
|
||||
@NotNull
|
||||
private static PsiType[] flattenAndRemoveDuplicates(@NotNull PsiType[] conjuncts) {
|
||||
try {
|
||||
final Set<PsiType> flattenConjuncts = PsiCapturedWildcardType.guard.doPreventingRecursion(conjuncts, true, () -> flatten(conjuncts, ContainerUtil.newLinkedHashSet()));
|
||||
final Set<PsiType> flattenConjuncts = flatten(conjuncts, ContainerUtil.newLinkedHashSet());
|
||||
if (flattenConjuncts == null) {
|
||||
return conjuncts;
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
abstract class Bug {
|
||||
void m1(){
|
||||
D<?> jobHandler = m();
|
||||
}
|
||||
|
||||
abstract <J extends C<? extends B>> J m();
|
||||
}
|
||||
|
||||
interface B {
|
||||
}
|
||||
|
||||
abstract class C<T extends B> {
|
||||
|
||||
}
|
||||
|
||||
abstract class D<T extends E> extends C<T> {
|
||||
|
||||
}
|
||||
|
||||
abstract class E<T extends String> implements B { }
|
||||
+1
@@ -116,6 +116,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
public void testIDEA149774() { doTest(); }
|
||||
public void testDisjunctionTypes() { doTest(); }
|
||||
public void testValidIntersectionTypeWithCapturedBounds() { doTest(); }
|
||||
public void testValidIntersectionTypeWithCapturedBounds1() { doTest(); }
|
||||
public void testPushErasedStateToArguments() { doTest(); }
|
||||
public void testStopAtStandaloneConditional() { doTest(); }
|
||||
public void testTransitiveInferenceVariableDependencies() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user