remove unused variable
[scpubgit/DX.git] / lib / DX / Step / ResolveProposition.pm
index 95ed10d..1edc2f2 100644 (file)
@@ -1,6 +1,7 @@
 package DX::Step::ResolveProposition;
 
 use DX::Step::EnterRecheck;
+use DX::Step::Backtrack;
 
 use Types::Standard qw(ArrayRef);
 use DX::Utils qw(deparse);
@@ -11,7 +12,7 @@ with 'DX::Role::Step';
 
 has actions => (is => 'ro', isa => ArrayRef[Action], required => 1);
 
-has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1);
+has depends_on => (is => 'ro', isa => ArrayRef[DependencySpec], required => 1);
 
 has resolves => (is => 'ro', isa => Proposition);
 
@@ -28,34 +29,29 @@ sub but_with_dependencies_on {
 }
 
 sub apply_to {
-  my ($self, $ss) = @_;
-  trace 'step.apply.old_hyp '.$self => $ss->current_hypothesis;
-  trace 'step.apply.actions '.$self => $self->actions;
-  my $new_ss = $self->_apply_to_ss($ss);
-  return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
-  trace 'step.apply.new_hyp '.$self => $new_ss->current_hypothesis;
+  my ($self, $old_ss) = @_;
   my $ns = do {
-    if (my $prop = $new_ss->next_proposition) {
+    if (my $prop = $old_ss->next_proposition) {
       DX::Step::ConsiderProposition->new(
         proposition => $prop
       )
     } else {
-      $new_ss->on_solution_step
+      $old_ss->on_solution_step
     }
   };
-  my $alt_step = $self->alternative_step;
-  return (
-    $new_ss->but(
-      next_step => $ns,
-      ($alt_step
-        ? (alternatives => [
-            [ $ss->current_hypothesis, $alt_step ],
-            @{$ss->alternatives}
-          ])
-        : ()
-      ),
+  my $ss = $old_ss->but(
+    next_step => $ns,
+    (@{$self->actions}
+      ? (adjustments_made => [
+          [ $self, $old_ss ],
+          @{$old_ss->adjustments_made}
+        ])
+      : ()
     ),
   );
+  my $new_ss = $self->_apply_to_ss($ss);
+  return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
+  return $new_ss;
 }
 
 sub _apply_to_ss {
@@ -79,22 +75,12 @@ sub _recheck_for {
   my $ss = $old_ss->but(
     next_step => DX::Step::EnterRecheck->new(
       proposition_list => \@recheck,
-      on_completion_step => DX::Step::MarkAsSolution->new,
+      on_completion_step => $old_ss->next_step,
+      on_failure_step => DX::Step::Backtrack->new,
     ),
   );
 
-  my $sp = DX::SearchProcess->new(
-    current_search_state => $ss,
-  );
-
-  my $sol_sp = $sp->find_solution;
-
-  unless ($sol_sp) {
-    trace 'step.recheck.fail' => 'argh';
-    return undef;
-  }
-
-  return $sol_sp->current_search_state->but(is_solution_state => 0);
+  return $ss;
 }
 
 1;