Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old deprecations, deprecate obsolete stuff #646

Merged
merged 9 commits into from
Feb 8, 2019
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,6 @@ Currently, the `@compat` macro supports the following syntaxes:

## New macros

* `@vectorize_1arg` and `@vectorize_2arg` are deprecated on Julia 0.6 in favor
of the broadcast syntax ([#17302]). `Compat.@dep_vectorize_1arg` and
`Compat.@dep_vectorize_2arg` are provided so that packages can still provide
the deprecated definitions without causing a depwarn in the package itself
before all the users are upgraded.

Packages are expected to use this until all users of the deprecated
vectorized function have migrated. These macros will be dropped when the
support for `0.6` is dropped from `Compat`.

* `@nospecialize` has been added ([#22666]).

* The logging macros `@error`, `@warn`, `@info` and `@debug` can be used as
Expand Down Expand Up @@ -448,7 +438,6 @@ includes this fix. Find the minimum version from there.
* Now specify the correct minimum version for Compat in your REQUIRE file by
`Compat <version>`

[#17302]: https://github.com/JuliaLang/julia/issues/17302
[#20005]: https://github.com/JuliaLang/julia/issues/20005
[#20974]: https://github.com/JuliaLang/julia/issues/20974
[#21197]: https://github.com/JuliaLang/julia/issues/21197
Expand Down
103 changes: 19 additions & 84 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,61 +87,6 @@ end
eval(mod, :(include_string($code, $fname)))
end

# PR #17302
# Provide a non-deprecated version of `@vectorize_(1|2)arg` macro which defines
# deprecated version of the function so that the depwarns can be fixed without
# breaking users.
# Packages are expected to use this to maintain the old API until all users
# of the deprecated vectorized function have migrated.
# These macros should raise a depwarn when the `0.5` support is dropped from
# `Compat` and be dropped when the support for `0.6` is dropped from `Compat`.
# Modified based on the version copied from 0.6 Base.
if VERSION < v"0.7.0-DEV.1211"
macro dep_vectorize_1arg(S, f)
S = esc(S)
f = esc(f)
T = esc(:T)
x = esc(:x)
AbsArr = esc(:AbstractArray)
## Depwarn to be enabled when 0.5 support is dropped.
# depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
# Symbol("@dep_vectorize_1arg"))
:(@deprecate $f{$T<:$S}($x::$AbsArr{$T}) @compat($f.($x)))
end

macro dep_vectorize_2arg(S, f)
S = esc(S)
f = esc(f)
T1 = esc(:T1)
T2 = esc(:T2)
x = esc(:x)
y = esc(:y)
AbsArr = esc(:AbstractArray)
## Depwarn to be enabled when 0.5 support is dropped.
# depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
# Symbol("@dep_vectorize_2arg"))
quote
@deprecate $f{$T1<:$S}($x::$S, $y::$AbsArr{$T1}) @compat($f.($x,$y))
@deprecate $f{$T1<:$S}($x::$AbsArr{$T1}, $y::$S) @compat($f.($x,$y))
@deprecate $f{$T1<:$S,$T2<:$S}($x::$AbsArr{$T1}, $y::$AbsArr{$T2}) @compat($f.($x,$y))
end
end
else
macro dep_vectorize_1arg(S, f)
AbstractArray = GlobalRef(Base, :AbstractArray)
return esc(:(@deprecate $f(x::$AbstractArray{T}) where {T<:$S} $f.(x)))
end

macro dep_vectorize_2arg(S, f)
AbstractArray = GlobalRef(Base, :AbstractArray)
return esc(quote
@deprecate $f(x::$S, y::$AbstractArray{T1}) where {T1<:$S} $f.(x, y)
@deprecate $f(x::$AbstractArray{T1}, y::$S) where {T1<:$S} $f.(x, y)
@deprecate $f(x::$AbstractArray{T1}, y::$AbstractArray{T2}) where {T1<:$S, T2<:$S} $f.(x, y)
end)
end
end

@static if !isdefined(Base, :isabstracttype) # VERSION < v"0.7.0-DEV.3475"
const isabstracttype = Base.isabstract
export isabstracttype
Expand All @@ -154,9 +99,6 @@ module TypeUtils
export isabstract, parameter_upper_bound, typename
end # module TypeUtils

# @view, @views, @__dot__
include("arraymacros.jl")

# https://github.com/JuliaLang/julia/pull/25646
@static if VERSION < v"0.7.0-DEV.3510"
# not exported
Expand All @@ -177,9 +119,6 @@ include("arraymacros.jl")
readuntil(f, d::Vector{T}; keep::Bool = false) where {T<:Union{UInt8,Char}} = convert(Vector{T}, readuntil(f, String(d), keep=keep))
end

# TODO deprecate/remove this unexported binding (along wiht its tests)
using Base: StringVector

# https://github.com/JuliaLang/julia/pull/22646
if VERSION < v"0.7.0-DEV.1139"
function invokelatest(f, args...; kwargs...)
Expand Down Expand Up @@ -646,8 +585,6 @@ else
if VERSION < v"0.7.0-DEV.3406"
$((:(using Base.Random: $f) for f in random_fields)...)
const seed! = Base.Random.srand
# these should be deprecated in favor of Compat.UUIDs.*
using Base.Random: uuid1, uuid4, uuid_version
else
$((:(using Random: $f) for f in random_fields)...)
import Random
Expand All @@ -656,10 +593,14 @@ else
else
using Random: seed!
end
if VERSION < v"0.7.0-DEV.3666"
# these should be deprecated in favor of Compat.UUIDs.*
using Random: uuid1, uuid4, uuid_version
end
end
if VERSION < v"0.7.0-DEV.3666"
import ..Compat
Base.@deprecate uuid1() Compat.UUIDs.uuid1() false
Base.@deprecate uuid1(rng) Compat.UUIDs.uuid1(rng) false
Base.@deprecate uuid4() Compat.UUIDs.uuid4() false
Base.@deprecate uuid4(rng) Compat.UUIDs.uuid4(rng) false
Base.@deprecate uuid_version(u) Compat.UUIDs.uuid_version(u) false
end

gentype(args...) = eltype(args...)
Expand Down Expand Up @@ -1485,13 +1426,6 @@ else
round(x; digits = nothing, sigdigits = nothing, base = 10) = Base.round(x, digits = digits, sigdigits = sigdigits, base = base)
end

# compatibiltiy with https://github.com/JuliaLang/julia/pull/26156
trunc(x, digits; base = 10) = trunc(x, digits = digits, base = base)
floor(x, digits; base = 10) = floor(x, digits = digits, base = base)
ceil(x, digits; base = 10) = ceil(x, digits = digits, base = base)
round(x, digits; base = 10) = round(x, digits = digits, base = base)
signif(x, digits; base = 10) = round(x, sigdigits = digits, base = base)

# https://github.com/JuliaLang/julia/pull/25872
if VERSION < v"0.7.0-DEV.3734"
if isdefined(Base, :open_flags)
Expand Down Expand Up @@ -1533,7 +1467,7 @@ if VERSION < v"0.7.0-DEV.3734"
buf = Base.IOBuffer(data, flags[1], flags[2], Int(maxsize))
else
size = sizehint !== nothing ? Int(sizehint) : maxsize != typemax(Int) ? Int(maxsize) : 32
buf = Base.IOBuffer(StringVector(size), flags[1], flags[2], Int(maxsize))
buf = Base.IOBuffer(Base.StringVector(size), flags[1], flags[2], Int(maxsize))
buf.data[:] = 0
end
if flags[4] # flags.truncate
Expand Down Expand Up @@ -1879,16 +1813,17 @@ if VERSION < v"0.7.0-beta2.143"
end
end

# This definition should be modified to throw an ArgumentError if neither
# `step` nor `length` are given and be limited to VERSION < v"1.1.0-DEV.506".
# However, there is a release with this definition, so we need to keep it around
# to avoid breakage.
function rangedepwarn(;step=nothing, length=nothing, kwargs...)
if step===nothing && length===nothing
Base.depwarn("`range(start, stop)` (with neither `length` nor `step` given) is deprecated, use `range(start, stop=stop)` instead.", :range)
end
end

if VERSION < v"1.1.0-DEV.506"
range(start, stop; kwargs...) = range(start; stop=stop, kwargs...)
else
# This method is restricted to Number, since we don't
# want to overwrite the (::Any, ::Any) method in Base.
range(start::Number, stop::Number; kwargs...) = range(start; stop=stop, kwargs...)
function range(start, stop; kwargs...)
rangedepwarn(;kwargs...)
range(start; stop=stop, kwargs...)
end
end

include("deprecated.jl")
Expand Down
7 changes: 0 additions & 7 deletions src/arraymacros.jl

This file was deleted.

104 changes: 76 additions & 28 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,36 +1,84 @@
function depwarn_ex(msg, name)
return quote
Base.depwarn($msg, Symbol($name))
Base.@deprecate_binding StringVector Base.StringVector false

# PR #17302
# Provide a non-deprecated version of `@vectorize_(1|2)arg` macro which defines
# deprecated version of the function so that the depwarns can be fixed without
# breaking users.
# Packages are expected to use this to maintain the old API until all users
# of the deprecated vectorized function have migrated.
# These macros should be dropped when the support for `0.6` is dropped from `Compat`.
# Modified based on the version copied from 0.6 Base.
if VERSION < v"0.7.0-DEV.1211"
macro dep_vectorize_1arg(S, f)
S = esc(S)
f = esc(f)
T = esc(:T)
x = esc(:x)
AbsArr = esc(:AbstractArray)
Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
Symbol("@dep_vectorize_1arg"))
:(@deprecate $f{$T<:$S}($x::$AbsArr{$T}) @compat($f.($x)))
end
end

primarytype(@nospecialize(t)) = t.name.wrapper
macro dep_vectorize_2arg(S, f)
S = esc(S)
f = esc(f)
T1 = esc(:T1)
T2 = esc(:T2)
x = esc(:x)
y = esc(:y)
AbsArr = esc(:AbstractArray)
Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
Symbol("@dep_vectorize_2arg"))
quote
@deprecate $f{$T1<:$S}($x::$S, $y::$AbsArr{$T1}) @compat($f.($x,$y))
@deprecate $f{$T1<:$S}($x::$AbsArr{$T1}, $y::$S) @compat($f.($x,$y))
@deprecate $f{$T1<:$S,$T2<:$S}($x::$AbsArr{$T1}, $y::$AbsArr{$T2}) @compat($f.($x,$y))
end
end
else
macro dep_vectorize_1arg(S, f)
AbstractArray = GlobalRef(Base, :AbstractArray)
Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
Symbol("@dep_vectorize_1arg"))
return esc(:(@deprecate $f(x::$AbstractArray{T}) where {T<:$S} $f.(x)))
end

export @functorize
macro functorize(f)
code = f === :scalarmax ? :(Base.scalarmax) :
f === :scalarmin ? :(Base.scalarmin) :
f === :centralizedabs2fun ? :(primarytype(typeof(Base.centralizedabs2fun(0)))) :
f
warning = depwarn_ex("@functorize is deprecated as functor objects are no longer supported in julia", "@functorize")
return quote
$warning
$code
macro dep_vectorize_2arg(S, f)
AbstractArray = GlobalRef(Base, :AbstractArray)
Base.depwarn("Implicit vectorized function is deprecated in favor of compact broadcast syntax.",
Symbol("@dep_vectorize_2arg"))
return esc(quote
@deprecate $f(x::$S, y::$AbstractArray{T1}) where {T1<:$S} $f.(x, y)
@deprecate $f(x::$AbstractArray{T1}, y::$S) where {T1<:$S} $f.(x, y)
@deprecate $f(x::$AbstractArray{T1}, y::$AbstractArray{T2}) where {T1<:$S, T2<:$S} $f.(x, y)
end)
end
end

Base.@deprecate_binding KERNEL Sys.KERNEL
Base.@deprecate_binding UTF8String Core.String
Base.@deprecate_binding ASCIIString Core.String
Base.@deprecate_binding unsafe_convert Base.unsafe_convert
Base.@deprecate_binding remote_do Distributed.remote_do
Base.@deprecate_binding Filesystem Base.Filesystem
Base.@deprecate_binding AsyncCondition Base.AsyncCondition
Base.@deprecate_binding promote_eltype_op Base.promote_eltype_op
@eval Base.@deprecate_binding $(Symbol("@irrational")) Base.$(Symbol("@irrational"))
@eval Base.@deprecate_binding $(Symbol("@blasfunc")) Compat.LinearAlgebra.BLAS.$(Symbol("@blasfunc"))
# compatibility with https://github.com/JuliaLang/julia/pull/26156
Base.@deprecate trunc(x, digits; base = 10) Compat.trunc(x, digits = digits, base = base) false
Base.@deprecate floor(x, digits; base = 10) Compat.floor(x, digits = digits, base = base) false
Base.@deprecate ceil(x, digits; base = 10) Compat.ceil(x, digits = digits, base = base) false
Base.@deprecate round(x, digits; base = 10) Compat.round(x, digits = digits, base = base) false
Base.@deprecate signif(x, digits; base = 10) Compat.round(x, sigdigits = digits, base = base) false

# to be deprecated:
if VERSION >= v"1.1.0-DEV.506"
# deprecation of range(start, stop) for earlier versions is done in Compat.jl
# This method is restricted to Number, since we don't
# want to overwrite the (::Any, ::Any) method in Base.
function range(start::Number, stop::Number; kwargs...)
rangedepwarn(;kwargs...)
range(start; stop=stop, kwargs...)
end
end

# this was defined for use with Julia versions prior to 0.5
# (see https://github.com/JuliaLang/Compat.jl/pull/316)
macro dotcompat(x)
Base.depwarn("`@dotcompat x` is deprecated, use `@compat @. x` instead.", Symbol("@dotcompat"))
esc(:(Compat.@compat @. $x))
end
export @dotcompat

# * `range(start, stop)` (without either `length` nor `step` given)
# * Compat.Random.uuid1, uuid4, uuid_version (in favour of Compat.UUIDs.*)
# Compat.Random.uuid1, uuid4, uuid_version are deprecated in Compat.jl
Loading