@@ -48,7 +48,7 @@ rather specific semantics of `copy`. Calling `copy` on a `TapedTask` does the fo
48
48
`position` field -- for this element we use the copy we made in step 1.
49
49
50
50
`_tape_copy` doesn't actually make a copy of the object at all if it is not either an
51
- `Array`, a `Ref`, or an instance of one of the types listed in the task's `deepcopy_type `
51
+ `Array`, a `Ref`, or an instance of one of the types listed in the task's `deepcopy_types `
52
52
field. If it is an instance of one of these types then `_tape_copy` just calls `deepcopy`.
53
53
54
54
This behaviour is plainly entirely acceptable if the argument to `_tape_copy` is a bits
@@ -77,13 +77,21 @@ this is a viable option.
77
77
"""
78
78
function Base. copy (t:: T ) where {T<: TapedTask }
79
79
captures = t. mc. oc. captures
80
- new_captures = map (Base. Fix2 (_tape_copy , t. deepcopy_types), captures)
80
+ new_captures = map (Base. Fix2 (_copy_capture , t. deepcopy_types), captures)
81
81
new_position = new_captures[end ] # baked in later on.
82
82
new_args = map (Base. Fix2 (_tape_copy, t. deepcopy_types), t. args)
83
83
new_mc = Mooncake. replace_captures (t. mc, new_captures)
84
84
return T (new_mc, new_args, new_position, t. deepcopy_types)
85
85
end
86
86
87
+ function _copy_capture (r:: Ref{T} , deepcopy_types:: Type ) where {T}
88
+ new_capture = Ref {T} ()
89
+ if isassigned (r)
90
+ new_capture[] = _tape_copy (r[], deepcopy_types)
91
+ end
92
+ return new_capture
93
+ end
94
+
87
95
_tape_copy (v, deepcopy_types:: Type ) = v isa deepcopy_types ? deepcopy (v) : v
88
96
89
97
# Not sure that we need this in the new implementation.
0 commit comments