Skip to content

Commit

Permalink
Add defalg methods to resolve potential dispatch ambiguities (#43426)
Browse files Browse the repository at this point in the history
We could also consider adding `defalg(v::AbstractArray{<:Number}) = DEFAULT_UNSTABLE`,
but it is unlikely that someone will want to do `Union` of `<:Number`
and something other than `Missing` that still would support comparison.

Relevant for JuliaStrings/InlineStrings.jl#21
(and other custom types that will want to add `defalg` support allowing
for `Union` with `Missing`).

(cherry picked from commit eb724e0)
  • Loading branch information
bkamins authored and KristofferC committed Feb 15, 2022
1 parent 2ca8b0c commit ed0658a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ end

defalg(v::AbstractArray) = DEFAULT_STABLE
defalg(v::AbstractArray{<:Union{Number, Missing}}) = DEFAULT_UNSTABLE
defalg(v::AbstractArray{Missing}) = DEFAULT_UNSTABLE
defalg(v::AbstractArray{Union{}}) = DEFAULT_UNSTABLE

function sort!(v::AbstractVector, alg::Algorithm, order::Ordering)
inds = axes(v,1)
Expand Down

0 comments on commit ed0658a

Please sign in to comment.