Skip to content

Commit 1da1b8d

Browse files
committed
Reduce consequences of method invalidation for Dict and Set
This aims to reduce disruption when adding methods to `convert` and `copymutable`.
1 parent b88d6df commit 1da1b8d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

base/dict.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ end
378378

379379
function setindex!(h::Dict{K,V}, v0, key::K) where V where K
380380
v = convert(V, v0)
381+
setindex!(h, v, key)
382+
end
383+
384+
function setindex!(h::Dict{K,V}, v::V, key::K) where V where K
381385
index = ht_keyindex2!(h, key)
382386

383387
if index > 0

base/set.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ delete!(s::Set, x) = (delete!(s.dict, x); s)
6767

6868
copy(s::Set) = copymutable(s)
6969

70+
copymutable(s::Set{T}) where {T} = Set{T}(s)
7071
# Set is the default mutable fall-back
7172
copymutable(s::AbstractSet{T}) where {T} = Set{T}(s)
7273

0 commit comments

Comments
 (0)