Skip to content

Commit bb2d863

Browse files
authored
deprecate @_(no)inline_meta in favor of no-arg @(no)inline (#41323)
v1.8 will publicly support these annotations within a function body and so we can replace all the usages of `@_inline_meta` and `@_noinline_meta` with each no-arg version. We may want to deprecate them rather than remove entirely them though, since I found a quite few packages rely on these "internal" macros... - <https://juliahub.com/ui/Search?q=%40_inline_meta&type=code> - <https://juliahub.com/ui/Search?q=%40_noinline_meta&type=code>
1 parent 6b365ac commit bb2d863

34 files changed

+279
-287
lines changed

base/Base.jl

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,42 @@ include(path::String) = include(Base, path)
2020
const is_primary_base_module = ccall(:jl_module_parent, Ref{Module}, (Any,), Base) === Core.Main
2121
ccall(:jl_set_istopmod, Cvoid, (Any, Bool), Base, is_primary_base_module)
2222

23-
# The real @inline macro is not available until after array.jl, so this
24-
# internal macro splices the meta Expr directly into the function body.
25-
macro _inline_meta()
26-
Expr(:meta, :inline)
27-
end
28-
macro _noinline_meta()
29-
Expr(:meta, :noinline)
30-
end
23+
# The @inline/@noinline macros that can be applied to a function declaration are not available
24+
# until after array.jl, and so we will mark them within a function body instead.
25+
macro inline() Expr(:meta, :inline) end
26+
macro noinline() Expr(:meta, :noinline) end
3127

3228
# Try to help prevent users from shooting them-selves in the foot
3329
# with ambiguities by defining a few common and critical operations
3430
# (and these don't need the extra convert code)
35-
getproperty(x::Module, f::Symbol) = (@_inline_meta; getfield(x, f))
31+
getproperty(x::Module, f::Symbol) = (@inline; getfield(x, f))
3632
setproperty!(x::Module, f::Symbol, v) = setfield!(x, f, v) # to get a decent error
37-
getproperty(x::Type, f::Symbol) = (@_inline_meta; getfield(x, f))
33+
getproperty(x::Type, f::Symbol) = (@inline; getfield(x, f))
3834
setproperty!(x::Type, f::Symbol, v) = error("setfield! fields of Types should not be changed")
39-
getproperty(x::Tuple, f::Int) = (@_inline_meta; getfield(x, f))
35+
getproperty(x::Tuple, f::Int) = (@inline; getfield(x, f))
4036
setproperty!(x::Tuple, f::Int, v) = setfield!(x, f, v) # to get a decent error
4137

42-
getproperty(x, f::Symbol) = (@_inline_meta; getfield(x, f))
38+
getproperty(x, f::Symbol) = (@inline; getfield(x, f))
4339
setproperty!(x, f::Symbol, v) = setfield!(x, f, convert(fieldtype(typeof(x), f), v))
4440

4541
dotgetproperty(x, f) = getproperty(x, f)
4642

47-
getproperty(x::Module, f::Symbol, order::Symbol) = (@_inline_meta; getfield(x, f, order))
43+
getproperty(x::Module, f::Symbol, order::Symbol) = (@inline; getfield(x, f, order))
4844
setproperty!(x::Module, f::Symbol, v, order::Symbol) = setfield!(x, f, v, order) # to get a decent error
49-
getproperty(x::Type, f::Symbol, order::Symbol) = (@_inline_meta; getfield(x, f, order))
45+
getproperty(x::Type, f::Symbol, order::Symbol) = (@inline; getfield(x, f, order))
5046
setproperty!(x::Type, f::Symbol, v, order::Symbol) = error("setfield! fields of Types should not be changed")
51-
getproperty(x::Tuple, f::Int, order::Symbol) = (@_inline_meta; getfield(x, f, order))
47+
getproperty(x::Tuple, f::Int, order::Symbol) = (@inline; getfield(x, f, order))
5248
setproperty!(x::Tuple, f::Int, v, order::Symbol) = setfield!(x, f, v, order) # to get a decent error
5349

54-
getproperty(x, f::Symbol, order::Symbol) = (@_inline_meta; getfield(x, f, order))
55-
setproperty!(x, f::Symbol, v, order::Symbol) = (@_inline_meta; setfield!(x, f, convert(fieldtype(typeof(x), f), v), order))
50+
getproperty(x, f::Symbol, order::Symbol) = (@inline; getfield(x, f, order))
51+
setproperty!(x, f::Symbol, v, order::Symbol) = (@inline; setfield!(x, f, convert(fieldtype(typeof(x), f), v), order))
5652

5753
swapproperty!(x, f::Symbol, v, order::Symbol=:notatomic) =
58-
(@_inline_meta; Core.swapfield!(x, f, convert(fieldtype(typeof(x), f), v), order))
54+
(@inline; Core.swapfield!(x, f, convert(fieldtype(typeof(x), f), v), order))
5955
modifyproperty!(x, f::Symbol, op, v, order::Symbol=:notatomic) =
60-
(@_inline_meta; Core.modifyfield!(x, f, op, v, order))
56+
(@inline; Core.modifyfield!(x, f, op, v, order))
6157
replaceproperty!(x, f::Symbol, expected, desired, success_order::Symbol=:notatomic, fail_order::Symbol=success_order) =
62-
(@_inline_meta; Core.replacefield!(x, f, expected, convert(fieldtype(typeof(x), f), desired), success_order, fail_order))
58+
(@inline; Core.replacefield!(x, f, expected, convert(fieldtype(typeof(x), f), desired), success_order, fail_order))
6359

6460

6561
include("coreio.jl")
@@ -107,9 +103,9 @@ include("options.jl")
107103
include("promotion.jl")
108104
include("tuple.jl")
109105
include("expr.jl")
110-
Pair{A, B}(@nospecialize(a), @nospecialize(b)) where {A, B} = (@_inline_meta; Pair{A, B}(convert(A, a)::A, convert(B, b)::B))
111-
#Pair{Any, B}(@nospecialize(a::Any), b) where {B} = (@_inline_meta; Pair{Any, B}(a, Base.convert(B, b)::B))
112-
#Pair{A, Any}(a, @nospecialize(b::Any)) where {A} = (@_inline_meta; Pair{A, Any}(Base.convert(A, a)::A, b))
106+
Pair{A, B}(@nospecialize(a), @nospecialize(b)) where {A, B} = (@inline; Pair{A, B}(convert(A, a)::A, convert(B, b)::B))
107+
#Pair{Any, B}(@nospecialize(a::Any), b) where {B} = (@inline; Pair{Any, B}(a, Base.convert(B, b)::B))
108+
#Pair{A, Any}(a, @nospecialize(b::Any)) where {A} = (@inline; Pair{A, Any}(Base.convert(A, a)::A, b))
113109
include("pair.jl")
114110
include("traits.jl")
115111
include("range.jl")

0 commit comments

Comments
 (0)