@@ -11,16 +11,23 @@ function promote_operation_fallback(op::Function, x::Type{<:AbstractArray}, y::T
1111 # We replace it by a more helpful error here.
1212 error (" `promote_operation($op , $x , $y )` not implemented yet, please report this." )
1313end
14- function promote_operation_fallback (:: typeof (/ ), :: Type{S} , :: Type{T} ) where {S,T}
15- return typeof (zero (S) / oneunit (T))
14+
15+ function promote_operation_fallback (
16+ op:: Function ,
17+ :: Type{S} ,
18+ :: Type{T} ,
19+ ) where {S,T}
20+ U = Base. promote_op (op, S, T)
21+ return return U == Union{} ? typeof (op (oneunit (S), oneunit (T))) : U
1622end
1723# Julia v1.0.x has trouble with inference with the `Vararg` method, see
1824# https://travis-ci.org/jump-dev/JuMP.jl/jobs/617606373
19- function promote_operation_fallback (op:: F , :: Type{S} , :: Type{T} ) where {F<: Function ,S,T}
20- return typeof (op (zero (S), zero (T)))
21- end
22- function promote_operation_fallback (op:: F , args:: Vararg{Type,N} ) where {F<: Function ,N}
23- return typeof (op (zero .(args)... ))
25+ function promote_operation_fallback (
26+ op:: F ,
27+ args:: Vararg{Type,N} ,
28+ ) where {F<: Function ,N}
29+ U = Base. promote_op (op, args... )
30+ return return U == Union{} ? typeof (op (oneunit .(args)... )) : U
2431end
2532promote_operation_fallback (:: typeof (* ), :: Type{T} ) where {T} = T
2633function promote_operation_fallback (
0 commit comments