Skip to content

Commit 65f74bc

Browse files
authored
Make deepcopy_internal infer for locks and conditions (#54506)
1 parent cf94072 commit 65f74bc

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
@@ -269,4 +269,6 @@ end
269269
@test a.lock !== b.lock
270270
@test islocked(a.lock)
271271
@test !islocked(b.lock)
272+
@inferred deepcopy(a)
273+
@inferred deepcopy(a.lock)
272274
end

0 commit comments

Comments
 (0)