Skip to content

Commit bc7e313

Browse files
Merge pull request #861 from JuliaSymbolics/as/small-array-specialize
fix: properly specialize on functions passed to `any`/`all`/`map`
2 parents ff92253 + 40069aa commit bc7e313

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/small_array.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Base.@propagate_inbounds function Base.pop!(x::Backing{T}) where {T}
8585
v
8686
end
8787

88-
function Base.any(f::Function, x::Backing)
88+
function Base.any(f::F, x::Backing) where {F <: Function}
8989
if x.len == 0
9090
return false
9191
elseif x.len == 1
@@ -98,7 +98,7 @@ function Base.any(f::Function, x::Backing)
9898
_unreachable()
9999
end
100100

101-
function Base.all(f::Function, x::Backing)
101+
function Base.all(f::F, x::Backing) where {F <: Function}
102102
if x.len == 0
103103
return true
104104
elseif x.len == 1
@@ -111,7 +111,7 @@ function Base.all(f::Function, x::Backing)
111111
_unreachable()
112112
end
113113

114-
function Base.map(f, x::Backing{T}) where {T}
114+
function Base.map(f::F, x::Backing{T}) where {F, T}
115115
if x.len == 0
116116
# StaticArrays does this, so we are only as bad as they are
117117
return Backing{Core.Compiler.return_type(f, Tuple{T})}()
@@ -307,9 +307,9 @@ end
307307

308308
Base.iterate(x::SmallVec) = iterate(x.data)
309309
Base.iterate(x::SmallVec, st::Int) = iterate(x.data, st)
310-
Base.any(f::Function, x::SmallVec) = any(f, x.data)
311-
Base.all(f::Function, x::SmallVec) = all(f, x.data)
312-
function Base.map(f, x::SmallVec{T, Vector{T}}) where {T}
310+
Base.any(f::F, x::SmallVec) where {F <: Function} = any(f, x.data)
311+
Base.all(f::F, x::SmallVec) where {F <: Function} = all(f, x.data)
312+
function Base.map(f::F, x::SmallVec{T, Vector{T}}) where {F, T}
313313
arr = map(f, x.data)
314314
SmallVec{eltype(arr),Vector{eltype(arr)}}(arr)
315315
end

0 commit comments

Comments
 (0)