From 8b1c45a3403013095f88f0b7ac68f54afea8bf5c Mon Sep 17 00:00:00 2001 From: john verzani Date: Thu, 26 May 2022 17:55:00 -0400 Subject: [PATCH] fix invalidations; close issue #403 (#406) * fix invalidations; close issue #403 * better fix, but not as general --- Project.toml | 2 +- src/common.jl | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 6cddc59a..7fd5c0b6 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "Polynomials" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" license = "MIT" author = "JuliaMath" -version = "3.1.0" +version = "3.1.1" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/common.jl b/src/common.jl index e89e8227..91efb896 100644 --- a/src/common.jl +++ b/src/common.jl @@ -426,13 +426,9 @@ LinearAlgebra.transpose!(p::AbstractPolynomial) = p Conversions =# Base.convert(::Type{P}, p::P) where {P <: AbstractPolynomial} = p Base.convert(P::Type{<:AbstractPolynomial}, x) = P(x) -function Base.convert(::Type{S}, p::P) where {S <: Number,T, P<:AbstractPolynomial{T}} - isconstant(p) && return convert(S, constantterm(p)) - throw(ArgumentError("Can't convert a nonconstant polynomial to type $S")) -end -function Base.convert(::Type{T}, p::P) where {T, P<:AbstractPolynomial{T}} - isconstant(p) && return constantterm(p) - throw(ArgumentError("Can't convert a nonconstant polynomial to type $S")) +function Base.convert(::Type{T}, p::AbstractPolynomial{T,X}) where {T <: Number,X} + isconstant(p) && return T(constantterm(p)) + throw(ArgumentError("Can't convert a nonconstant polynomial to type $T")) end # Methods to ensure that matrices of polynomials behave as desired