Skip to content

Commit

Permalink
Mark typeintersect pure for Julia 1.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Apr 24, 2023
1 parent 2f50491 commit 375dee8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/arraymath.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inline zeros(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = zeros(Base.typeintersect(SA, AbstractArray{Float64}))
@inline zeros(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = zeros(typeintersect(SA, AbstractArray{Float64}))
@inline zeros(::Type{SA}) where {SA <: StaticArray{<:Tuple, T}} where T = _zeros(Size(SA), SA)
@generated function _zeros(::Size{s}, ::Type{SA}) where {s, SA <: StaticArray}
T = eltype(SA)
Expand All @@ -16,7 +16,7 @@
end
end

@inline ones(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = ones(Base.typeintersect(SA, AbstractArray{Float64}))
@inline ones(::Type{SA}) where {SA <: StaticArray{<:Tuple}} = ones(typeintersect(SA, AbstractArray{Float64}))
@inline ones(::Type{SA}) where {SA <: StaticArray{<:Tuple, T}} where T = _ones(Size(SA), SA)
@generated function _ones(::Size{s}, ::Type{SA}) where {s, SA <: StaticArray}
T = eltype(SA)
Expand Down
4 changes: 2 additions & 2 deletions src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function adapt_size(::Type{SA}, x) where {SA<:StaticArray}
_no_precise_size(SA, x)
end
end
SA′ = Base.typeintersect(SA, StaticArrayNoEltype{SZ,tuple_length(SZ)})
SA′ = typeintersect(SA, StaticArrayNoEltype{SZ,tuple_length(SZ)})
SA′ === Union{} && _no_precise_size(SA, x)
return SA′
end
Expand All @@ -139,7 +139,7 @@ function adapt_eltype(::Type{SA}, x) where {SA<:StaticArray}
else
eltype(x)
end
return Base.typeintersect(SA, AbstractArray{T})
return typeintersect(SA, AbstractArray{T})
end

need_rewrap(::Type{<:StaticArray}, x) = false
Expand Down
6 changes: 6 additions & 0 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ else
const var"@_inline_meta" = Base.var"@inline"
end

# Julia 1.9 removed the `@pure` annotation in favor off Concrete-Eval
# This behaves unfavorable with `julia --check-bounds=no`
Base.@pure function typeintersect(@nospecialize(a),@nospecialize(b))
Base.typeintersect(a,b)
end

# For convenience
TupleN{T,N} = NTuple{N,T}

Expand Down

0 comments on commit 375dee8

Please sign in to comment.