@@ -990,3 +990,19 @@ p0 = copy(p)
990
990
@test isequal (identity .(Vector{<: Union{Int, Missing} }[[1 , 2 ],[missing , 1 ]]),
991
991
[[1 , 2 ],[missing , 1 ]])
992
992
end
993
+
994
+ # test the dimension promotion provided by the generic
995
+ # BroadcastStyle(::AbstractArrayStyle, ::AbstractArrayStyle)
996
+ struct CustomStyle{T,N} <: Broadcast.AbstractArrayStyle{N} end
997
+ Broadcast. BroadcastStyle (:: CustomStyle{:A,N} , :: CustomStyle{:B,N} ) where {N} = CustomStyle {:A,N} ()
998
+ CustomStyle {T,N} (:: Val{M} ) where {T,N,M} = CustomStyle {T,M} ()
999
+ # test this isn't spoiled:
1000
+ @test @inferred (Broadcast. result_style (CustomStyle {:A,1} (), CustomStyle {:B,1} ())) ==
1001
+ @inferred (Broadcast. result_style (CustomStyle {:B,1} (), CustomStyle {:A,1} ())) == CustomStyle {:A,1} ()
1002
+ # test dimension promotion works here:
1003
+ @test @inferred (Broadcast. result_style (CustomStyle {:A,1} (), CustomStyle {:A,2} ())) == CustomStyle {:A,2} ()
1004
+ # here the user would need to specify a custom rule:
1005
+ @test @inferred (Broadcast. result_style (CustomStyle {:A,1} (), CustomStyle {:B,2} ())) ==
1006
+ @inferred (Broadcast. result_style (CustomStyle {:B,2} (), CustomStyle {:A,1} ())) ==
1007
+ @inferred (Broadcast. result_style (CustomStyle {:A,2} (), CustomStyle {:B,1} ())) ==
1008
+ @inferred (Broadcast. result_style (CustomStyle {:B,1} (), CustomStyle {:A,2} ())) == Broadcast. ArrayConflict ()
0 commit comments