@@ -453,19 +453,12 @@ function StructArrayStyle{S, M}(::Val{N}) where {S, M, N}
453453 return StructArrayStyle {T, N} ()
454454end
455455
456- _dimmax (a:: Integer , b:: Integer ) = max (a, b)
457- _dimmax (:: Type{Any} , :: Integer ) = Any
458- _dimmax (:: Integer ,:: Type{Any} ) = Any
459- _dimmax (:: Type{Any} ,:: Type{Any} ) = Any
460-
461456# StructArrayStyle is a wrapped style.
462457# Here we try our best to resolve style conflict.
463458function BroadcastStyle (b:: AbstractArrayStyle{M} , a:: StructArrayStyle{S, N} ) where {S, N, M}
459+ N′ = M === Any || N === Any ? Any : max (M, N)
464460 S′ = Broadcast. result_style (S (), b)
465- if S′ isa StructArrayStyle # avoid double wrap
466- return typeof (S′)(Val {_dimmax(N, M)} ())
467- end
468- StructArrayStyle {typeof(S′), _dimmax(N, M)} ()
461+ return S′ isa StructArrayStyle ? typeof (S′)(Val {N′} ()) : StructArrayStyle {typeof(S′), N′} ()
469462end
470463BroadcastStyle (:: StructArrayStyle , :: DefaultArrayStyle ) = Unknown ()
471464
@@ -482,8 +475,7 @@ BroadcastStyle(::Type{SA}) where {SA<:StructArray} = StructArrayStyle{typeof(cst
482475# Here we use `similar` defined for `S` to build the dest Array.
483476function Base. similar (bc:: Broadcasted{StructArrayStyle{S, N}} , :: Type{ElType} ) where {S, N, ElType}
484477 bc′ = convert (Broadcasted{S}, bc)
485- isnonemptystructtype (ElType) || return similar (bc′, ElType)
486- return buildfromschema (T -> similar (bc′, T), ElType)
478+ return isnonemptystructtype (ElType) ? buildfromschema (T -> similar (bc′, T), ElType) : similar (bc′, ElType)
487479end
488480
489481# Unwrapper to recover the behaviour defined by parent style.
0 commit comments