Skip to content

Commit d742f67

Browse files
authored
Merge pull request #456 from JuliaLang/teh/expunge_oldcode
Delete outdated deprecated code
2 parents 95e21c5 + 43a3b57 commit d742f67

File tree

3 files changed

+0
-251
lines changed

3 files changed

+0
-251
lines changed

src/deprecated.jl

-137
Original file line numberDiff line numberDiff line change
@@ -6,143 +6,6 @@ function depwarn_ex(msg, name)
66
end
77
end
88

9-
macro Dict(pairs...)
10-
esc(Expr(:block, depwarn_ex("@Dict is deprecated, use Dict instead", "@Dict"),
11-
Expr(:call, :Dict, pairs...)))
12-
end
13-
14-
macro AnyDict(pairs...)
15-
esc(Expr(:block, depwarn_ex("@AnyDict is deprecated, use Dict{Any,Any} instead", "@AnyDict"),
16-
Expr(:call, :(Base.AnyDict), pairs...)))
17-
end
18-
19-
module CompatCartesian
20-
21-
import ..Compat: depwarn_ex
22-
23-
export @ngenerate, @nsplat
24-
25-
macro ngenerate(itersym, returntypeexpr, funcexpr)
26-
if isa(funcexpr, Expr) && funcexpr.head == :macrocall && funcexpr.args[1] == Symbol("@inline")
27-
funcexpr = Base._inline(funcexpr.args[2])
28-
end
29-
isfuncexpr(funcexpr) || error("Requires a function expression")
30-
esc(Expr(:block, depwarn_ex("@ngenerate is deprecated, used @generated function or (preferably) tuples/CartesianIndex instead", "@ngenerate"),
31-
_ngenerate(itersym, funcexpr)))
32-
end
33-
34-
function _ngenerate(itersym::Symbol, funcexpr::Expr)
35-
prototype = funcexpr.args[1]
36-
body = funcexpr.args[2]
37-
varname, T = get_splatinfo(prototype, itersym)
38-
ex = Expr(:$, itersym)
39-
sreplace!(body, itersym, ex)
40-
if !isempty(varname)
41-
prototype, body = _nsplat(prototype, body, varname, T, itersym)
42-
else
43-
body = Expr(:quote, body)
44-
end
45-
Expr(:stagedfunction, prototype, body)
46-
end
47-
48-
macro nsplat(itersym, args...)
49-
if length(args) == 1
50-
funcexpr = args[1]
51-
elseif length(args) == 2
52-
funcexpr = args[2]
53-
else
54-
error("Wrong number of arguments")
55-
end
56-
if isa(funcexpr, Expr) && funcexpr.head == :macrocall && funcexpr.args[1] == Symbol("@inline")
57-
funcexpr = Base._inline(funcexpr.args[2])
58-
end
59-
isfuncexpr(funcexpr) || error("Second argument must be a function expression")
60-
prototype = funcexpr.args[1]
61-
body = funcexpr.args[2]
62-
varname, T = get_splatinfo(prototype, itersym)
63-
isempty(varname) && error("Last argument must be a splat")
64-
prototype, body = _nsplat(prototype, body, varname, T, itersym)
65-
esc(Expr(:block, depwarn_ex("@nsplat is deprecated, using inlining instead", "@nsplat"),
66-
Expr(:stagedfunction, prototype, body)))
67-
end
68-
69-
function _nsplat(prototype, body, varname, T, itersym)
70-
varsym = Symbol(varname)
71-
prototype.args[end] = Expr(:..., Expr(:(::), varsym, T)) # :($varsym::$T...)
72-
varquot = Expr(:quote, varsym)
73-
bodyquot = Expr(:quote, body)
74-
newbody = quote
75-
$itersym = length($varsym)
76-
quote
77-
Base.Cartesian.@nexprs $($itersym) (d->$($(Expr(:quote, Symbol(varsym, "_d")))) = $($varquot)[d])
78-
$(Compat.CompatCartesian.resolvesplats!($bodyquot, $varquot, $itersym))
79-
end
80-
end
81-
prototype, newbody
82-
end
83-
84-
# If using the syntax that will need "desplatting",
85-
# myfunction(A::AbstractArray, I::NTuple{N, Int}...)
86-
# return the variable name (as a string) and type
87-
function get_splatinfo(ex::Expr, itersym::Symbol)
88-
if ex.head == :call
89-
a = ex.args[end]
90-
if isa(a, Expr) && a.head == :... && length(a.args) == 1
91-
b = a.args[1]
92-
if isa(b, Expr) && b.head == :(::)
93-
varname = string(b.args[1])
94-
c = b.args[2]
95-
if isa(c, Expr) && c.head == :curly && c.args[1] == :NTuple && c.args[2] == itersym
96-
T = c.args[3]
97-
return varname, T
98-
end
99-
end
100-
end
101-
end
102-
"", Void
103-
end
104-
105-
resolvesplats!(arg, varname, N) = arg
106-
function resolvesplats!(ex::Expr, varname, N::Int)
107-
if ex.head == :call
108-
for i = 2:length(ex.args)-1
109-
resolvesplats!(ex.args[i], varname, N)
110-
end
111-
a = ex.args[end]
112-
if isa(a, Expr) && a.head == :... && a.args[1] == Symbol(varname)
113-
ex.args[end] = :($varname[1]) # Expr(:ref, varname, 1)
114-
for i = 2:N
115-
push!(ex.args, :($varname[$i])) # Expr(:ref, varname, i))
116-
end
117-
else
118-
resolvesplats!(a, varname, N)
119-
end
120-
else
121-
for i = 1:length(ex.args)
122-
resolvesplats!(ex.args[i], varname, N)
123-
end
124-
end
125-
ex
126-
end
127-
128-
isfuncexpr(ex::Expr) =
129-
ex.head == :function || (ex.head == :(=) && typeof(ex.args[1]) == Expr && ex.args[1].head == :call)
130-
isfuncexpr(arg) = false
131-
132-
sreplace!(arg, sym, val) = arg
133-
function sreplace!(ex::Expr, sym, val)
134-
for i = 1:length(ex.args)
135-
ex.args[i] = sreplace!(ex.args[i], sym, val)
136-
end
137-
ex
138-
end
139-
sreplace!(s::Symbol, sym, val) = s == sym ? val : s
140-
141-
end
142-
143-
using .CompatCartesian
144-
export @ngenerate, @nsplat
145-
1469
function primarytype(@nospecialize(t))
14710
tn = t.name
14811
if isdefined(tn, :primary)

test/deprecated.jl

-109
This file was deleted.

test/runtests.jl

-5
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,6 @@ let c = CartesianIndices(1:3, 1:2), l = LinearIndices(1:3, 1:2)
12081208
@test l[vec(c)] == collect(1:6)
12091209
end
12101210

1211-
12121211
if !isdefined(Base, Symbol("@info"))
12131212
let fname = tempname()
12141213
try
@@ -1298,8 +1297,4 @@ end
12981297
@test lastindex(zeros(4)) == 4
12991298
@test lastindex(zeros(4,4)) == 16
13001299

1301-
if VERSION < v"0.6.0"
1302-
include("deprecated.jl")
1303-
end
1304-
13051300
nothing

0 commit comments

Comments
 (0)