internal/core/dep: adapt Recurse to mimic dep.Visit
https://cuelang.org/cl/556460 swapped two indirect calls to func Visit
with calls to the method visitor.visit, allowing better memory reuse.
However, it missed that the two call sites weren't equal semantically:
* The call site in internal/core/export/self.go called markDeps,
which then called dep.Visit with the Config.Descend option set.
* The call site in tools/flow/tasks called markTaskDependencies,
which then called dep.Visit with the Config.Dynamic option set.
The former caused Visit to call visitor.visit, like our new code,
but the latter caused Visit to call visitor.dynamic,
which our new code certainly does not do.
To fix this unintentional change in behavior in the refactor above,
factor out the logic based on Dynamic so that Recurse can reuse it,
and remember the value of Dynamic in visitor so Recurse can apply it.
In the added test output, we can now see that root.run depends on
root.prepare again, like v0.5.0 did, and unlike the previous commit.
Fixes #2517.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I299000385ffdfa79218ddbe8b8faa901b5006a9d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557477
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>