@@ -28,6 +28,58 @@ function promote_rule_constant(::Type{S}, PT::Type{<:APL{T}}) where {S, T}
2828end
2929Base. promote_rule (:: Type{PT} , :: Type{T} ) where {T, PT<: APL } = promote_rule_constant (T, PT)
3030Base. promote_rule (:: Type{T} , :: Type{PT} ) where {T, PT<: APL } = promote_rule_constant (T, PT)
31+ # Resolve method ambiguity with Base:
32+ Base. promote_rule (:: Type{Any} , :: Type{<:APL} ) = Any
33+
34+ # We don't have any information on the MultivariatePolynomials implementation,
35+ # so we won't be able to convert the constant to `APL`.
36+ promote_rule_constant (:: Type , PT:: Type{AbstractMonomialLike} ) = Any
37+ promote_rule_constant (:: Type , PT:: Type{AbstractTermLike{T}} ) where {T} = Any
38+ promote_rule_constant (:: Type , PT:: Type{AbstractTermLike} ) = Any
39+ promote_rule_constant (:: Type , PT:: Type{APL{T}} ) where {T} = Any
40+ promote_rule_constant (:: Type , PT:: Type{APL} ) = Any
41+
42+ # AbstractMonomialLike{T}
43+ Base. promote_rule (:: Type{AbstractMonomialLike} , :: Type{<:AbstractMonomialLike} ) = AbstractMonomialLike
44+ Base. promote_rule (:: Type{<:AbstractMonomialLike} , :: Type{AbstractMonomialLike} ) = AbstractMonomialLike
45+ Base. promote_rule (:: Type{AbstractMonomialLike} , :: Type{<:AbstractTermLike{T}} ) where {T} = _atl (Int, T)
46+ Base. promote_rule (:: Type{<:AbstractTermLike{T}} , :: Type{AbstractMonomialLike} ) where {T} = _atl (Int, T)
47+ Base. promote_rule (:: Type{AbstractMonomialLike} , :: Type{AbstractTermLike{T}} ) where {T} = _atl (Int, T)
48+ Base. promote_rule (:: Type{AbstractTermLike{T}} , :: Type{AbstractMonomialLike} ) where {T} = _atl (Int, T)
49+ Base. promote_rule (:: Type{AbstractMonomialLike} , :: Type{<:APL{T}} ) where {T} = _apl (Int, T)
50+ Base. promote_rule (:: Type{<:APL{T}} , :: Type{AbstractMonomialLike} ) where {T} = _apl (Int, T)
51+ Base. promote_rule (:: Type{AbstractMonomialLike} , :: Type{APL{T}} ) where {T} = _apl (Int, T)
52+ Base. promote_rule (:: Type{APL{T}} , :: Type{AbstractMonomialLike} ) where {T} = _apl (Int, T)
53+
54+ # AbstractTermLike{T}
55+ _atl (:: Type{T} , :: Type{T} ) where {T} = AbstractTermLike{T}
56+ _atl (:: Type , :: Type ) = AbstractTermLike
57+ __atl (:: Type{T} , :: Type{<:AbstractTermLike{S}} ) where {S,T} = _atl (T, S)
58+ __atl (:: Type{T} , :: Type{<:APL{S}} ) where {S,T} = _apl (T, S)
59+ Base. promote_rule (:: Type{AbstractTermLike{T}} , P:: Type{<:AbstractTermLike{S}} ) where {S,T} = _atl (T, S)
60+ Base. promote_rule (P:: Type{<:AbstractTermLike{S}} , :: Type{AbstractTermLike{T}} ) where {S,T} = _atl (T, S)
61+ Base. promote_rule (:: Type{AbstractTermLike{T}} , P:: Type{<:APL{S}} ) where {S,T} = _apl (T, S)
62+ Base. promote_rule (P:: Type{<:APL{S}} , :: Type{AbstractTermLike{T}} ) where {S,T} = _apl (T, S)
63+ Base. promote_rule (:: Type{AbstractTermLike{T}} , P:: Type{APL{S}} ) where {S,T} = _apl (T, S)
64+ Base. promote_rule (P:: Type{APL{S}} , :: Type{AbstractTermLike{T}} ) where {S,T} = _apl (T, S)
65+
66+ # AbstractTermLike
67+ Base. promote_rule (:: Type{AbstractTermLike} , :: Type{<:AbstractTermLike} ) = AbstractTermLike
68+ Base. promote_rule (:: Type{<:AbstractTermLike} , :: Type{AbstractTermLike} ) = AbstractTermLike
69+ Base. promote_rule (:: Type{AbstractTermLike} , :: Type{<:APL} ) = APL
70+ Base. promote_rule (:: Type{<:APL} , :: Type{AbstractTermLike} ) = APL
71+ Base. promote_rule (:: Type{AbstractTermLike} , :: Type{APL} ) = APL
72+ Base. promote_rule (:: Type{APL} , :: Type{AbstractTermLike} ) = APL
73+
74+ # APL{T}
75+ _apl (:: Type{T} , :: Type{T} ) where {T} = APL{T}
76+ _apl (:: Type , :: Type ) = APL
77+ Base. promote_rule (:: Type{APL{T}} , :: Type{<:APL{S}} ) where {S,T} = _apl (S, T)
78+ Base. promote_rule (:: Type{<:APL{S}} , :: Type{APL{T}} ) where {S,T} = _apl (S, T)
79+
80+ # APL
81+ Base. promote_rule (:: Type{APL} , :: Type{<:APL} ) = APL
82+ Base. promote_rule (:: Type{<:APL} , :: Type{APL} ) = APL
3183
3284# Rational
3385promote_rule_constant (:: Type{T} , :: Type{RationalPoly{NT, DT}} ) where {T, NT, DT} = RationalPoly{promote_type (T, NT), promote_type (DT, termtype (DT))}
0 commit comments