Skip to content

Commit

Permalink
Make deepcopy_internal infer for locks and conditions (#54506)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored May 17, 2024
1 parent cf94072 commit 65f74bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/deepcopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ end

function deepcopy_internal(x::AbstractLock, stackdict::IdDict)
if haskey(stackdict, x)
return stackdict[x]
return stackdict[x]::typeof(x)
end
y = typeof(x)()
stackdict[x] = y
Expand All @@ -166,7 +166,7 @@ end

function deepcopy_internal(x::GenericCondition, stackdict::IdDict)
if haskey(stackdict, x)
return stackdict[x]
return stackdict[x]::typeof(x)
end
y = typeof(x)(deepcopy_internal(x.lock, stackdict))
stackdict[x] = y
Expand Down
2 changes: 2 additions & 0 deletions test/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,6 @@ end
@test a.lock !== b.lock
@test islocked(a.lock)
@test !islocked(b.lock)
@inferred deepcopy(a)
@inferred deepcopy(a.lock)
end

0 comments on commit 65f74bc

Please sign in to comment.