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`).
  • Loading branch information
bkamins authored Jan 18, 2022
1 parent c5158f4 commit eb724e0
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 eb724e0

Please sign in to comment.