From 6e05345be73e8e99a08e9de5639f37251a51230d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 26 Jun 2020 21:29:05 +0200 Subject: [PATCH] Solver: Move analyze handling of multiconflict rule to clearer location This way we're not looking at the previous decision at the top of the loop but working with the current decision at the bottom --- src/Composer/DependencyResolver/Solver.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 5f1170ccf..772d022d8 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -417,18 +417,6 @@ class Solver } unset($literal); - if ($decisionId > 0) { - $decision = $this->decisions->atOffset($decisionId-1); - if ($rule !== $decision[Decisions::DECISION_REASON] && $decision[Decisions::DECISION_REASON] instanceof MultiConflictRule) { - $num++; - foreach ($decision[Decisions::DECISION_REASON]->getLiterals() as $literal) { - if (!$this->decisions->satisfy($literal)) { - $seen[abs($literal)] = true; - } - } - } - } - $l1retry = true; while ($l1retry) { $l1retry = false; @@ -481,6 +469,15 @@ class Solver $rule = $decision[Decisions::DECISION_REASON]; if ($rule instanceof MultiConflictRule) { + // there is only ever exactly one positive decision in a multiconflict rule + foreach ($rule->getLiterals() as $literal) { + if (!isset($seen[abs($literal)]) && !$this->decisions->satisfy($literal)) { + $num++; + $seen[abs($literal)] = true; + break; + } + } + $l1retry = true; } }