Skip to content

Commit 2de6d1c

Browse files
committed
Simplify promote_type_fallback
1 parent e470c6b commit 2de6d1c

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

src/interface.jl

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,11 @@ function promote_operation_fallback(
2525
)
2626
end
2727

28-
_instantiate_zero(::Type{S}) where {S} = zero(S)
29-
_instantiate_oneunit(::Type{S}) where {S} = oneunit(S)
30-
31-
# this is valid because Irrational numbers are defined in global scope as const
32-
_instantiate(::Type{S}) where {S<:Irrational} = S()
33-
_instantiate_zero(::Type{S}) where {S<:AbstractIrrational} = _instantiate(S)
34-
_instantiate_oneunit(::Type{S}) where {S<:AbstractIrrational} = _instantiate(S)
35-
36-
# Julia v1.0.x has trouble with inference with the `Vararg` method, see
37-
# https://travis-ci.org/jump-dev/JuMP.jl/jobs/617606373
38-
function promote_operation_fallback(
39-
op::Union{typeof(/),typeof(div)},
40-
::Type{S},
41-
::Type{T},
42-
) where {S,T}
43-
return typeof(op(_instantiate_zero(S), _instantiate_oneunit(T)))
44-
end
45-
46-
function promote_operation_fallback(
47-
op::F,
48-
::Type{S},
49-
::Type{T},
50-
) where {F<:Function,S,T}
51-
return typeof(op(_instantiate_zero(S), _instantiate_zero(T)))
52-
end
53-
5428
function promote_operation_fallback(
5529
op::F,
5630
args::Vararg{Type,N},
5731
) where {F<:Function,N}
58-
return typeof(op(_instantiate_zero.(args)...))
32+
return promote_type(args...)
5933
end
6034

6135
promote_operation_fallback(::typeof(*), ::Type{T}) where {T} = T

0 commit comments

Comments
 (0)