Skip to content

Commit 030201a

Browse files
committed
Make UnsafeIndex(::ArrayStyle, ::Type{Tuple}) more generic
1 parent 0c239e8 commit 030201a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/indexing.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ Base.promote_rule(::Type{X}, ::Type{Y}) where {X<:UnsafeIndex,Y<:UnsafeGetElemen
6565
@generated function UnsafeIndex(s::ArrayStyle, ::Type{T}) where {N,T<:Tuple{Vararg{<:Any,N}}}
6666
if N === 0
6767
return UnsafeGetElement()
68-
elseif N === 1
69-
return UnsafeIndex(s, T.parameters[1])
7068
else
71-
out = typeof(UnsafeIndex(s, T.parameters[1]))
72-
for i in 2:N
73-
out = promote_type(out, typeof(UnsafeIndex(s, T.parameters[i])))
69+
e = Expr(:call, promote_type)
70+
for p in T.parameters
71+
push!(e.args, :(typeof(ArrayInterface.UnsafeIndex(s, $p))))
7472
end
75-
return out()
73+
return Expr(:block, Expr(:meta, :inline), Expr(:call, e))
7674
end
7775
end
7876

0 commit comments

Comments
 (0)