瀏覽代碼

Implement handling of conflicts with learned rules

Nils Adermann 13 年之前
父節點
當前提交
52565a5935
共有 1 個文件被更改,包括 10 次插入9 次删除
  1. 10 9
      src/Composer/DependencyResolver/Solver.php

+ 10 - 9
src/Composer/DependencyResolver/Solver.php

@@ -1187,7 +1187,7 @@ class Solver
             assert($newRule != null);
             $this->addRule(RuleSet::TYPE_LEARNED, $newRule);
 
-            $this->learnedWhy[] = $why;
+            $this->learnedWhy[$newRule->getId()] = $why;
 
             $this->watch2OnHighest($newRule);
             $this->addWatchesToRule($newRule);
@@ -1304,7 +1304,7 @@ class Solver
             }
         }
 
-        $why = $this->learnedPool[count($this->learnedPool) - 1];
+        $why = count($this->learnedPool) - 1;
 
         $newRule = new Rule($learnedLiterals, self::RULE_LEARNED, $why);
 
@@ -1316,13 +1316,14 @@ class Solver
         $why = $conflictRule->getId();
 
         if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
-            throw new \RuntimeException("handling conflicts with learned rules unimplemented");
-                /** TODO:
-      for (i = solv->learnt_why.elements[why - solv->learntrules]; solv->learnt_pool.elements[i]; i++)
-    if (solv->learnt_pool.elements[i] > 0)
-      analyze_unsolvable_rule(solv, solv->rules + solv->learnt_pool.elements[i], lastweakp);
-      return;
-*/
+
+            $learnedWhy = $this->learnedWhy[$why];
+            $problem = $this->learnedPool[$learnedWhy];
+
+            foreach ($problem as $problemRule) {
+                $this->analyzeUnsolvableRule($problemRule, $lastWeakWhy);
+            }
+            return;
         }
 
         if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {