Skip to content

Commit

Permalink
Unpirate Union{}[xs...]
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Nov 6, 2019
1 parent e437921 commit 7e68add
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/initializers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const SA_F64 = SA{Float64}
@inline similar_type(::Type{SA}, ::Size{S}) where {S} = SArray{Tuple{S...}}
@inline similar_type(::Type{SA{T}}, ::Size{S}) where {T,S} = SArray{Tuple{S...}, T}

@inline Base.getindex(::Type{Union{}}) = invoke(getindex, Tuple{Type}, Union{})
@inline Base.getindex(::Type{Union{}}, xs::Vararg{T,N}) where {T,N} =
invoke(getindex, Tuple{Type,Vararg{T,N}}, Union{}, xs...)
@inline Base.getindex(sa::Type{<:SA}, xs...) = similar_type(sa, Size(length(xs)))(xs)
@inline Base.typed_vcat(sa::Type{<:SA}, xs::Number...) = similar_type(sa, Size(length(xs)))(xs)
@inline Base.typed_hcat(sa::Type{<:SA}, xs::Number...) = similar_type(sa, Size(1,length(xs)))(xs)
Expand Down
1 change: 1 addition & 0 deletions test/initializers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ SA_test_hvcat(x,T) = SA{T}[1 x x;

# https://github.com/JuliaArrays/StaticArrays.jl/pull/685
@test Union{}[] isa Vector{Union{}}
@test_throws MethodError Union{}[1]

end

0 comments on commit 7e68add

Please sign in to comment.