mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: take into account backward variable dependencies (IDEA-123951)
This commit is contained in:
+14
-2
@@ -27,6 +27,7 @@ import com.intellij.psi.util.*;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -221,7 +222,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) {
|
||||
final Set<ConstraintFormula> additionalConstraints = new HashSet<ConstraintFormula>();
|
||||
final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
|
||||
if (parameters.length > 0) {
|
||||
collectAdditionalConstraints(parameters, args, properties.getMethod(), PsiSubstitutor.EMPTY, additionalConstraints, properties.isVarargs(), true);
|
||||
}
|
||||
@@ -881,7 +882,7 @@ public class InferenceSession {
|
||||
|
||||
private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints) {
|
||||
|
||||
final Set<ConstraintFormula> subset = new HashSet<ConstraintFormula>();
|
||||
final Set<ConstraintFormula> subset = new LinkedHashSet<ConstraintFormula>();
|
||||
final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
|
||||
for (ConstraintFormula constraint : additionalConstraints) {
|
||||
if (constraint instanceof InputOutputConstraintFormula) {
|
||||
@@ -899,8 +900,19 @@ public class InferenceSession {
|
||||
if (inputVariables != null) {
|
||||
boolean dependsOnOutput = false;
|
||||
for (InferenceVariable inputVariable : inputVariables) {
|
||||
if (dependsOnOutput) break;
|
||||
if (inputVariable.hasInstantiation(this)) continue;
|
||||
final Set<InferenceVariable> dependencies = inputVariable.getDependencies(this);
|
||||
dependencies.add(inputVariable);
|
||||
if (!hasCapture(inputVariable)) {
|
||||
for (InferenceVariable outputVariable : outputVariables) {
|
||||
if (ContainerUtil.intersects(outputVariable.getDependencies(this), dependencies)) {
|
||||
dependsOnOutput = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies.retainAll(outputVariables);
|
||||
if (!dependencies.isEmpty()) {
|
||||
dependsOnOutput = true;
|
||||
|
||||
+10
@@ -115,6 +115,16 @@ public class InferenceVariable extends LightTypeParameter {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public boolean hasInstantiation(InferenceSession session) {
|
||||
List<PsiType> bounds = getBounds(InferenceBound.EQ);
|
||||
if (bounds != null) {
|
||||
for (PsiType bound : bounds) {
|
||||
if (session.isProperType(bound)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isThrownBound() {
|
||||
return myThrownBound;
|
||||
}
|
||||
|
||||
-1
@@ -102,7 +102,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Bombed(day = 20, month = Calendar.AUGUST)
|
||||
public void testIDEA123951() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user