20
20
21
21
macro deprecate (old,new,ex= true )
22
22
meta = Expr (:meta , :noinline )
23
+ @gensym oldmtname
23
24
if isa (old,Symbol)
24
25
oldname = Expr (:quote ,old)
25
26
newname = Expr (:quote ,new)
@@ -28,31 +29,30 @@ macro deprecate(old,new,ex=true)
28
29
:(function $ (esc (old))(args... )
29
30
$ meta
30
31
depwarn (string ($ oldname," is deprecated, use " ,$ newname," instead." ),
31
- $ oldname )
32
+ $ oldmtname )
32
33
$ (esc (new))(args... )
33
- end ))
34
+ end ),
35
+ :(const $ oldmtname = Core. Typeof ($ (esc (old))). name. mt. name))
34
36
elseif isa (old,Expr) && old. head == :call
35
37
remove_linenums! (new)
36
38
oldcall = sprint (show_unquoted, old)
37
39
newcall = sprint (show_unquoted, new)
38
40
oldsym = if isa (old. args[1 ],Symbol)
39
- old. args[1 ]
41
+ old. args[1 ]:: Symbol
40
42
elseif isa (old. args[1 ],Expr) && old. args[1 ]. head == :curly
41
- old. args[1 ]. args[1 ]
43
+ old. args[1 ]. args[1 ]:: Symbol
42
44
else
43
45
error (" invalid usage of @deprecate" )
44
46
end
45
- # work around #20220, deprecation for Array repeating over and over
46
- # TODO : remove the special case when 0.6 deprecations are removed
47
- oldname = Expr (:quote , oldsym in (:Array , :SharedArray ) ? :Type : oldsym)
48
47
Expr (:toplevel ,
49
- Expr (:export ,esc (oldsym)),
48
+ ex ? Expr (:export ,esc (oldsym)) : nothing ,
50
49
:($ (esc (old)) = begin
51
50
$ meta
52
51
depwarn (string ($ oldcall," is deprecated, use " ,$ newcall," instead." ),
53
- $ oldname )
52
+ $ oldmtname )
54
53
$ (esc (new))
55
- end ))
54
+ end ),
55
+ :(const $ oldmtname = Core. Typeof ($ (esc (oldsym))). name. mt. name))
56
56
else
57
57
error (" invalid usage of @deprecate" )
58
58
end
@@ -1142,7 +1142,6 @@ function partial_linear_indexing_warning(n)
1142
1142
end
1143
1143
1144
1144
# Deprecate Array(T, dims...) in favor of proper type constructors
1145
- # TODO : when removing these, get rid of the special casing in the @deprecate macro up top
1146
1145
@deprecate Array {T,N} (:: Type{T} , d:: NTuple{N,Int} ) Array {T} (d)
1147
1146
@deprecate Array {T} (:: Type{T} , d:: Int... ) Array {T} (d... )
1148
1147
@deprecate Array {T} (:: Type{T} , m:: Int ) Array {T} (m)
0 commit comments