diff --git a/src/intervals/construction.jl b/src/intervals/construction.jl index eee9705f..7f19cff2 100644 --- a/src/intervals/construction.jl +++ b/src/intervals/construction.jl @@ -367,10 +367,6 @@ isguaranteed(x::Complex{<:Interval}) = isguaranteed(real(x)) & isguaranteed(imag isguaranteed(::Number) = false -Interval{T}(x::Interval) where {T<:NumTypes} = convert(Interval{T}, x) # needed to resolve method ambiguity -Interval{T}(x::Real) where {T<:NumTypes} = convert(Interval{T}, x) -Interval(x::Real) = Interval{promote_numtype(typeof(x), typeof(x))}(x) - # """ @@ -563,6 +559,10 @@ Base.promote_rule(::Type{T}, ::Type{Interval{S}}) where {T<:AbstractIrrational,S # conversion +Interval{T}(x::Real) where {T<:NumTypes} = convert(Interval{T}, x) +Interval(x::Real) = Interval{promote_numtype(numtype(x), numtype(x))}(x) +Interval{T}(x::Interval) where {T<:NumTypes} = convert(Interval{T}, x) # needed to resolve method ambiguity + Base.convert(::Type{Interval{T}}, x::Interval) where {T<:NumTypes} = interval(T, x) function Base.convert(::Type{Interval{T}}, x::Complex{<:Interval}) where {T<:NumTypes} diff --git a/src/intervals/exact_literals.jl b/src/intervals/exact_literals.jl index 3933db9d..5f7d939d 100644 --- a/src/intervals/exact_literals.jl +++ b/src/intervals/exact_literals.jl @@ -87,6 +87,9 @@ Base.promote_rule(::Type{ExactReal{T}}, ::Type{ExactReal{S}}) where {T<:Real,S<: # to BareInterval +BareInterval{T}(x::ExactReal) where {T<:NumTypes} = convert(BareInterval{T}, x) +BareInterval(x::ExactReal) = BareInterval{promote_numtype(numtype(x.value), numtype(x.value))}(x) + Base.convert(::Type{BareInterval{T}}, x::ExactReal) where {T<:NumTypes} = bareinterval(T, x.value) Base.promote_rule(::Type{BareInterval{T}}, ::Type{ExactReal{S}}) where {T<:NumTypes,S<:Real} = @@ -106,8 +109,8 @@ Base.promote_rule(::Type{ExactReal{T}}, ::Type{Interval{S}}) where {T<:Real,S<:N # to Real (::Type{T})(x::ExactReal) where {T<:Real} = convert(T, x) -Interval{T}(x::ExactReal) where {T<:NumTypes} = convert(Interval{T}, x) # to resolve ambiguity -Interval(x::ExactReal) = Interval{promote_numtype(typeof(x.value), typeof(x.value))}(x) # to resolve ambiguity +Interval{T}(x::ExactReal) where {T<:NumTypes} = convert(Interval{T}, x) # needed to resolve ambiguity +Interval(x::ExactReal) = Interval{promote_numtype(numtype(x.value), numtype(x.value))}(x) # needed to resolve ambiguity Base.convert(::Type{T}, x::ExactReal) where {T<:Real} = convert(T, x.value)