diff --git a/base/deepcopy.jl b/base/deepcopy.jl index 317d999004c42f..74c9d2b49c1234 100644 --- a/base/deepcopy.jl +++ b/base/deepcopy.jl @@ -140,7 +140,7 @@ function deepcopy_internal(x::GenericCondition, stackdict::IdDict) if haskey(stackdict, x) return stackdict[x] end - y = typeof(x)(deepcopy_internal(x.lock)) + y = typeof(x)(deepcopy_internal(x.lock, stackdict)) stackdict[x] = y return y end diff --git a/test/copy.jl b/test/copy.jl index c4fcff40f2b3ff..633beee5f2af32 100644 --- a/test/copy.jl +++ b/test/copy.jl @@ -252,3 +252,19 @@ end a = [1:3;] @test copyto!(a, 2:3, 1:1, a, 1:2, 1:1) == [1;1:2;] end + +@testset "`deepcopy` a `GenericCondition`" begin + a = Base.GenericCondition(ReentrantLock()) + @test !islocked(a.lock) + lock(a.lock) + @test islocked(a.lock) + b = deepcopy(a) + @test typeof(a) === typeof(b) + @test a != b + @test a !== b + @test typeof(a.lock) === typeof(b.lock) + @test a.lock != b.lock + @test a.lock !== b.lock + @test islocked(a.lock) + @test !islocked(b.lock) +end