File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -20,28 +20,22 @@ function promote_operation_fallback(
2020end
2121
2222function promote_operation_fallback (
23- :: typeof ( / ) ,
23+ op :: Function ,
2424 :: Type{S} ,
2525 :: Type{T} ,
2626) where {S,T}
27- return typeof (zero (S) / oneunit (T))
27+ U = Base. promote_op (op, S, T)
28+ return return U == Union{} ? typeof (op (oneunit (S), oneunit (T))) : U
2829end
2930
3031# Julia v1.0.x has trouble with inference with the `Vararg` method, see
3132# https://travis-ci.org/jump-dev/JuMP.jl/jobs/617606373
32- function promote_operation_fallback (
33- op:: F ,
34- :: Type{S} ,
35- :: Type{T} ,
36- ) where {F<: Function ,S,T}
37- return typeof (op (zero (S), zero (T)))
38- end
39-
4033function promote_operation_fallback (
4134 op:: F ,
4235 args:: Vararg{Type,N} ,
4336) where {F<: Function ,N}
44- return typeof (op (zero .(args)... ))
37+ U = Base. promote_op (op, args... )
38+ return return U == Union{} ? typeof (op (oneunit .(args)... )) : U
4539end
4640
4741promote_operation_fallback (:: typeof (* ), :: Type{T} ) where {T} = T
You can’t perform that action at this time.
0 commit comments