@@ -199,7 +199,10 @@ const depsdir = joinpath(dirname(@__DIR__), "deps")
199199const 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"""
204207const 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
11831186end
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
0 commit comments