From 5883a74bcd743bbee356c335df3d4afff1532556 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 9 Aug 2017 11:26:47 -0700 Subject: [PATCH] Fix vectorization deprecation macros for Julia 0.7 (#394) --- src/Compat.jl | 70 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index 3c323316edcf7..d17b59cfa09f8 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -169,33 +169,49 @@ end # 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. -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)) +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