mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: resolve bounds which are not mentioned by additional constraints before starting algorithm
(cherry picked from commit f4c3b393d749a7ad27936014c932492643a277e4)
This commit is contained in:
+20
-1
@@ -788,6 +788,25 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
private boolean proceedWithAdditionalConstraints(Set<ConstraintFormula> additionalConstraints) {
|
||||
final Set<InferenceVariable> mentionedVars = new HashSet<InferenceVariable>();
|
||||
for (ConstraintFormula constraint : additionalConstraints) {
|
||||
if (constraint instanceof InputOutputConstraintFormula) {
|
||||
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
|
||||
if (inputVariables != null) {
|
||||
mentionedVars.addAll(inputVariables);
|
||||
}
|
||||
final Set<InferenceVariable> outputVariables = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this);
|
||||
if (outputVariables != null) {
|
||||
mentionedVars.addAll(outputVariables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Set<InferenceVariable> readyVariables = new LinkedHashSet<InferenceVariable>(myInferenceVariables.values());
|
||||
readyVariables.removeAll(mentionedVars);
|
||||
|
||||
final PsiSubstitutor siteSubstitutor = resolveBounds(readyVariables, mySiteSubstitutor);
|
||||
|
||||
while (!additionalConstraints.isEmpty()) {
|
||||
//extract subset of constraints
|
||||
final Set<ConstraintFormula> subset = buildSubset(additionalConstraints);
|
||||
@@ -804,7 +823,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
//resolve input variables
|
||||
PsiSubstitutor substitutor = resolveSubset(varsToResolve, mySiteSubstitutor);
|
||||
PsiSubstitutor substitutor = resolveSubset(varsToResolve, siteSubstitutor);
|
||||
|
||||
if (substitutor == null) {
|
||||
return false;
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.function.Function;
|
||||
|
||||
abstract class Test {
|
||||
abstract <T, A, R> Collector<T, A, R> create(Foo<A> foo, Function<A,R> fun);
|
||||
abstract <Ts> Foo<Ts[]> toArray(Ts identity);
|
||||
|
||||
<Tf> Collector<Tf, ?, Tf> foo(Tf t) {
|
||||
return create(toArray(t), a -> a[0]);
|
||||
}
|
||||
|
||||
interface Collector<T1, A1, R1> {}
|
||||
class Foo<D> {}
|
||||
}
|
||||
+4
@@ -162,6 +162,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAdditionalConstraintDependsOnNonMentionedVars() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user