|
8 | 8 | # `map(f, as::Union{<:StaticArray,AbstractArray}...)` which included at least one `StaticArray`
|
9 | 9 | # this is not the case on 0.7 and we instead hope to find a StaticArray in the first two arguments.
|
10 | 10 | @inline function map(f, a1::StaticArray, as::AbstractArray...)
|
11 |
| - _map(f, same_size(a1, as...), a1, as...) |
| 11 | + _map(f, a1, as...) |
12 | 12 | end
|
13 | 13 | @inline function map(f, a1::AbstractArray, a2::StaticArray, as::AbstractArray...)
|
14 |
| - _map(f, same_size(a1, a2, as...), a1, a2, as...) |
| 14 | + _map(f, a1, a2, as...) |
15 | 15 | end
|
16 | 16 | @inline function map(f, a1::StaticArray, a2::StaticArray, as::AbstractArray...)
|
17 |
| - _map(f, same_size(a1, a2, as...), a1, a2, as...) |
| 17 | + _map(f, a1, a2, as...) |
18 | 18 | end
|
19 | 19 |
|
20 |
| -@generated function _map(f, ::Size{S}, a::AbstractArray...) where {S} |
| 20 | +@generated function _map(f, a::AbstractArray...) |
| 21 | + i = findfirst(ai -> ai <: StaticArray, a) |
| 22 | + if i === nothing |
| 23 | + return :(throw(ArgumentError("No StaticArray found in argument list"))) |
| 24 | + end |
| 25 | + # Passing the Size as an argument to _map leads to inference issues when |
| 26 | + # recursively mapping over nested StaticArrays (see issue #593). Calling |
| 27 | + # Size in the generator here is valid because a[i] is known to be a |
| 28 | + # StaticArray for which the default Size method is correct. If wrapped |
| 29 | + # StaticArrays (with a custom Size method) are to be supported, this will |
| 30 | + # no longer be valid. |
| 31 | + S = Size(a[i]) |
21 | 32 | exprs = Vector{Expr}(undef, prod(S))
|
22 | 33 | for i ∈ 1:prod(S)
|
23 | 34 | tmp = [:(a[$j][$i]) for j ∈ 1:length(a)]
|
|
26 | 37 |
|
27 | 38 | return quote
|
28 | 39 | @_inline_meta
|
| 40 | + S = same_size(a...) |
29 | 41 | @inbounds elements = tuple($(exprs...))
|
30 |
| - @inbounds return similar_type(typeof(_first(a...)), eltype(elements), Size(S))(elements) |
| 42 | + @inbounds return similar_type(typeof(_first(a...)), eltype(elements), S)(elements) |
31 | 43 | end
|
32 | 44 | end
|
33 | 45 |
|
|
0 commit comments