move resolution step construction later
[scpubgit/DX.git] / lib / DX / Step / ResolveProposition.pm
index c714458..6cf99b9 100644 (file)
@@ -52,24 +52,29 @@ sub apply_to {
       ] ],
     ] ]
   ] ];
-  my $ss = $old_ss->but(
-    next_step => DX::Step::CompleteResolution->new(
-      original_search_state => $old_ss,
-      resolution_space => $rspace,
-    )
-  );
   my $old_hyp = $old_ss->current_hypothesis;
   (my $hyp, my @recheck) = $old_hyp->with_resolution(
     $prop, $vdeps, $res->actions
   );
-  return $ss->but(next_step => DX::Step::Backtrack->new) unless $hyp;
-  return $ss->but(current_hypothesis => $hyp) unless @recheck;
-  return $ss->but(
+  unless ($hyp) {
+    return $old_ss->but(
+      next_step
+        => $rspace->remaining_resolution_space->next_step
+    );
+  }
+  my $next_step = DX::Step::CompleteResolution->new(
+    original_search_state => $old_ss,
+    resolution_space => $rspace,
+  );
+  unless (@recheck) {
+    return $old_ss->but(next_step => $next_step, current_hypothesis => $hyp);
+  }
+  return $old_ss->but(
     current_hypothesis => $hyp,
     next_step => DX::Step::EnterRecheck->new(
       proposition_list => \@recheck,
-      on_completion_step => $ss->next_step,
-      on_failure_step => $rspace->remaining_resolution_space->next_step,
+      on_completion_step => $next_step,
+      resolution_space => $rspace,
     ),
   );
 }