Skip to content

Commit 2b6f488

Browse files
LilithHafnerKristofferC
authored andcommitted
Make deepcopy_internal infer for locks and conditions (#54506)
(cherry picked from commit 65f74bc)
1 parent 3c2894d commit 2b6f488

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

base/deepcopy.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ end
157157

158158
function deepcopy_internal(x::AbstractLock, stackdict::IdDict)
159159
if haskey(stackdict, x)
160-
return stackdict[x]
160+
return stackdict[x]::typeof(x)
161161
end
162162
y = typeof(x)()
163163
stackdict[x] = y
@@ -166,7 +166,7 @@ end
166166

167167
function deepcopy_internal(x::GenericCondition, stackdict::IdDict)
168168
if haskey(stackdict, x)
169-
return stackdict[x]
169+
return stackdict[x]::typeof(x)
170170
end
171171
y = typeof(x)(deepcopy_internal(x.lock, stackdict))
172172
stackdict[x] = y

test/copy.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,6 @@ end
267267
@test a.lock !== b.lock
268268
@test islocked(a.lock)
269269
@test !islocked(b.lock)
270+
@inferred deepcopy(a)
271+
@inferred deepcopy(a.lock)
270272
end

0 commit comments

Comments
 (0)