Skip to content

Commit 0c3b3c6

Browse files
authored
Merge pull request #15 from tkoolen/fix-map-ambiguity
Fix map! ambiguity.
2 parents 307e801 + 35bc8f6 commit 0c3b3c6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/TypeSortedCollections.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Base.@pure num_types(::Type{<:TypeSortedCollection{<:Any, N}}) where {N} = N
9292
num_types(x::TypeSortedCollection) = num_types(typeof(x))
9393

9494
const TSCOrAbstractVector{N} = Union{<:TypeSortedCollection{<:Any, N}, AbstractVector}
95+
const TSCOrAbstractArray{N} = Union{<:TypeSortedCollection{<:Any, N}, AbstractArray}
9596

9697
Base.isempty(x::TypeSortedCollection) = all(isempty, x.data)
9798
Base.empty!(x::TypeSortedCollection) = foreach(empty!, x.data)
@@ -131,7 +132,7 @@ end
131132
@inline indices_match(vali::Val, indices::Vector{Int}, a1, as...) = indices_match(vali, indices, a1) && indices_match(vali, indices, as...)
132133
@noinline indices_match_fail() = throw(ArgumentError("Indices of TypeSortedCollections do not match."))
133134

134-
@generated function Base.map!(f, dest::TSCOrAbstractVector{N}, args::TSCOrAbstractVector{N}...) where {N}
135+
@generated function Base.map!(f, dest::TSCOrAbstractArray{N}, args::TSCOrAbstractArray{N}...) where {N} # TSCOrAbstract*Array* to avoid ambiguities with map!(f, ::AbstractArray, ::AbstractArray...)
135136
expr = Expr(:block)
136137
push!(expr.args, :(Base.@_inline_meta))
137138
push!(expr.args, :(leading_tsc = first_tsc(dest, args...)))

test/runtests.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ g(x::Int64, y1::Int64, y2::Float64) = x - y1 * y2
1313
end
1414

1515
@testset "ambiguities" begin
16-
base_ambiguities = detect_ambiguities(Base, Core)
17-
tsc_ambiguities = setdiff(detect_ambiguities(TypeSortedCollections, Base, Core), base_ambiguities)
18-
@test isempty(tsc_ambiguities)
16+
@test isempty(detect_ambiguities(Base, Core, TypeSortedCollections))
1917
end
2018

2119
@testset "general collection interface" begin

0 commit comments

Comments
 (0)