From 46110b07310b27887c0774b4875f67d7959613f3 Mon Sep 17 00:00:00 2001 From: Eric Davies Date: Fri, 18 Aug 2017 14:20:22 -0500 Subject: [PATCH] Deprecate ^(x, p::Integer) --- NEWS.md | 3 +++ base/deprecated.jl | 2 ++ base/intfuncs.jl | 1 - 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 9f3f5b6f2ebfa..c8c3e02d777ad 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1020,6 +1020,9 @@ Deprecated or removed * `DateTime()`, `Date()`, and `Time()` have been deprecated, instead use `DateTime(1)`, `Date(1)` and `Time(0)` respectively ([#23724]). + * The fallback method `^(x, p::Integer)` is deprecated. If your type relied on this definition, + add a method such as `^(x::MyType, p::Integer) = Base.power_by_squaring(x, p)` ([#23332]). + Command-line option changes --------------------------- diff --git a/base/deprecated.jl b/base/deprecated.jl index 70da1cba7b8b1..cf022e6e22f86 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1352,6 +1352,8 @@ end @deprecate IOBuffer(read::Bool, write::Bool) IOBuffer(read=read, write=write) @deprecate IOBuffer(maxsize::Integer) IOBuffer(read=true, write=true, maxsize=maxsize) +# PR #23332 +@deprecate ^(x, p::Integer) power_by_squaring(x,p) # END 0.7 deprecations diff --git a/base/intfuncs.jl b/base/intfuncs.jl index c69069d86f311..3fdf40cf8b008 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -219,7 +219,6 @@ end ^(x::T, p::T) where {T<:Integer} = power_by_squaring(x,p) ^(x::Number, p::Integer) = power_by_squaring(x,p) -^(x, p::Integer) = power_by_squaring(x,p) # x^p for any literal integer p is lowered to Base.literal_pow(^, x, Val(p)) # to enable compile-time optimizations specialized to p.