Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Utilities/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3190,7 +3190,22 @@ function Base.one(F::Type{<:TypedScalarLike{T}}) where {T}
return convert(F, one(T))
end

Base.promote_rule(::Type{F}, ::Type{T}) where {T,F<:TypedScalarLike{T}} = F
# !!! note
# These two `promote_rules` are written explicitly instead of
# `TypedScalarLike` in order to avoid a method invalidation.
function Base.promote_rule(
F::Type{MOI.ScalarAffineFunction{T}},
::Type{T},
) where {T}
return F
end

function Base.promote_rule(
F::Type{MOI.ScalarQuadraticFunction{T}},
::Type{T},
) where {T}
return F
end

function operate_coefficient(f, term::MOI.ScalarAffineTerm)
return MOI.ScalarAffineTerm(f(term.coefficient), term.variable)
Expand Down