Skip to content

Commit 8442dae

Browse files
committed
invokelatest (from #352 and #359)
1 parent bd7f2db commit 8442dae

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ Currently, the `@compat` macro supports the following syntaxes:
133133

134134
* The `isabstract`, `parameter_upper_bound`, `typename` reflection methods were added in Julia 0.6. This package re-exports these from the `Compat.TypeUtils` submodule. On earlier versions of julia, that module contains the same functions, but operating on the pre-0.6 type system representation.
135135

136-
* `Compat.invokelatest` is equivalent to `Base.invokelatest` in Julia 0.6,
137-
but works in Julia 0.5+, and allows you to guarantee that a function call
138-
invokes the latest version of a function ([#19784]).
139-
140136
* `Compat.invokelatest` supports keywords ([#22646]).
141137

142138
* `@__MODULE__` is aliased to `current_module()` for Julia versions 0.6 and below. Versions of `Base.binding_module`, `expand`, `macroexpand`, and `include_string` were added that accept a module as the first argument. ([#22064])
@@ -454,7 +450,6 @@ includes this fix. Find the minimum version from there.
454450
[#13681]: https://github.com/JuliaLang/julia/issues/13681
455451
[#17302]: https://github.com/JuliaLang/julia/issues/17302
456452
[#17323]: https://github.com/JuliaLang/julia/issues/17323
457-
[#19784]: https://github.com/JuliaLang/julia/issues/19784
458453
[#20005]: https://github.com/JuliaLang/julia/issues/20005
459454
[#20974]: https://github.com/JuliaLang/julia/issues/20974
460455
[#21197]: https://github.com/JuliaLang/julia/issues/21197

src/Compat.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,14 @@ end
183183
# TODO deprecate/remove this unexported binding (along wiht its tests)
184184
using Base: StringVector
185185

186-
# https://github.com/JuliaLang/julia/pull/19784
187-
@static if isdefined(Base, :invokelatest)
188-
# https://github.com/JuliaLang/julia/pull/22646
189-
if VERSION < v"0.7.0-DEV.1139"
190-
function invokelatest(f, args...; kwargs...)
191-
inner() = f(args...; kwargs...)
192-
Base.invokelatest(inner)
193-
end
194-
else
195-
import Base.invokelatest
196-
end
197-
else
186+
# https://github.com/JuliaLang/julia/pull/22646
187+
if VERSION < v"0.7.0-DEV.1139"
198188
function invokelatest(f, args...; kwargs...)
199-
kw = [Expr(:kw, k, QuoteNode(v)) for (k, v) in kwargs]
200-
eval(current_module(), Expr(:call, f, map(QuoteNode, args)..., kw...))
189+
inner() = f(args...; kwargs...)
190+
Base.invokelatest(inner)
201191
end
192+
else
193+
import Base.invokelatest
202194
end
203195

204196
# https://github.com/JuliaLang/julia/pull/21197

test/runtests.jl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,7 @@ using Compat.Test
180180
@test (@__MODULE__) === Test22064
181181
end
182182

183-
# invokelatest
184-
issue19774(x) = 1
185-
let foo() = begin
186-
eval(:(issue19774(x::Int) = 2))
187-
return Compat.invokelatest(issue19774, 0)
188-
end
189-
@test foo() == 2
190-
end
191-
cm359() = @__MODULE__
192-
@test Compat.invokelatest(cm359) === @__MODULE__
193-
183+
# invokelatest with keywords
194184
pr22646(x; y=0) = 1
195185
let foo() = begin
196186
eval(:(pr22646(x::Int; y=0) = 2))

0 commit comments

Comments
 (0)