Skip to content

Commit 13cf6bd

Browse files
committed
make compatible with all Julia versions
1 parent 2d06943 commit 13cf6bd

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/legacy_loading.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function parse_pkg_files(id::PkgId)
156156
# To reduce compiler latency, use runtime dispatch for `queue_includes!`.
157157
# `queue_includes!` requires compilation of the whole parsing/expression-splitting infrastructure,
158158
# and it's better to wait to compile it until we actually need it.
159-
Base.invoke_in_world(worldage[], queue_includes!, pkgdata, id)
159+
invoke_revisefunc(worldage[], queue_includes!, pkgdata, id)
160160
return pkgdata
161161
end
162162

src/loading.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function parse_pkg_files(id::PkgId)
4848
# To reduce compiler latency, use runtime dispatch for `queue_includes!`.
4949
# `queue_includes!` requires compilation of the whole parsing/expression-splitting infrastructure,
5050
# and it's better to wait to compile it until we actually need it.
51-
Base.invoke_in_world(worldage[], queue_includes!, pkgdata, id)
51+
invoke_revisefunc(worldage[], queue_includes!, pkgdata, id)
5252
return pkgdata
5353
end
5454

src/packagedef.jl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ const depsdir = joinpath(dirname(@__DIR__), "deps")
199199
const silencefile = Ref(joinpath(depsdir, "silence.txt")) # Ref so that tests don't clobber
200200

201201
"""
202-
world age
202+
Revise.worldage
203+
204+
The world age Revise was started in. Needed so that Revise doesn't delete methods
205+
from under itself.
203206
"""
204207
const worldage = Ref{Union{Nothing,UInt}}(nothing)
205208

@@ -270,7 +273,7 @@ function delete_missing!(exs_sigs_old::ExprsSigs, exs_sigs_new)
270273
#try # guard against serialization errors if the type isn't defined on the worker
271274
future = remotecall(Core.eval, p, Main, :(delete_method_by_sig($sig)))
272275
finalizer(future) do f
273-
Base.invoke_in_world(worldage[], Distributed.finalize_ref, f)
276+
Base.invoke_revisefunc(worldage[], Distributed.finalize_ref, f)
274277
end
275278
#catch
276279
#end
@@ -1182,11 +1185,26 @@ function maybe_set_prompt_color(color)
11821185
return nothing
11831186
end
11841187

1188+
if VERSION < v"1.6.0-DEV.1162"
1189+
const invoke_revisefunc = Base.invokelatest
1190+
const lower_in_reviseworld = Meta.lower
1191+
else
1192+
function invoke_revisefunc(f, args...; kwargs...)
1193+
return Base.invoke_in_world(worldage[], f, args...; kwargs...)
1194+
end
1195+
function lower_in_reviseworld(m::Module, @nospecialize(ex))
1196+
return ccall(:jl_expand_in_world, Any,
1197+
(Any, Ref{Module}, Cstring, Cint, Csize_t),
1198+
ex, m, "none", 0, world,
1199+
)
1200+
end
1201+
end
1202+
11851203
# On Julia 1.5.0-DEV.282 and higher, we can just use an AST transformation
11861204
# This uses invokelatest not for reasons of world age but to ensure that the call is made at runtime.
11871205
# This allows `revise_first` to be compiled without compiling `revise` itself, and greatly
11881206
# reduces the overhead of using Revise.
1189-
revise_first(ex) = Expr(:toplevel, :(isempty($revision_queue) || Base.invoke_in_world($(worldage[]), $revise)), ex)
1207+
revise_first(ex) = Expr(:toplevel, :(isempty($revision_queue) || Base.invoke_revisefunc($revise)), ex)
11901208

11911209
@noinline function run_backend(backend)
11921210
while true

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ using Revise.CodeTracking
44
using Revise.JuliaInterpreter
55
using Test
66

7+
@show VERSION
8+
79
@test isempty(detect_ambiguities(Revise))
810

911
using Pkg, Unicode, Distributed, InteractiveUtils, REPL, UUIDs

0 commit comments

Comments
 (0)