Skip to content

Commit 8f1552e

Browse files
authored
Insulate Revise methods from invalidation (#724)
Loading a package like StaticArrays invalidates much of Revise's code. This protects it by using runtime-dispatch for the invalidating calls.
1 parent e28a2bc commit 8f1552e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1717
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
1818

1919
[compat]
20-
CodeTracking = "1.1"
20+
CodeTracking = "1.2"
2121
JuliaInterpreter = "0.9"
2222
LoweredCodeUtils = "2.3"
2323
OrderedCollections = "1"

src/packagedef.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,7 @@ end
415415
CodeTrackingMethodInfo(ex::Expr) = CodeTrackingMethodInfo([ex], Any[], Set{Union{GlobalRef,Symbol}}(), Pair{Module,String}[])
416416

417417
function add_signature!(methodinfo::CodeTrackingMethodInfo, @nospecialize(sig), ln)
418-
locdefs = get(CodeTracking.method_info, sig, nothing)
419-
locdefs === nothing && (locdefs = CodeTracking.method_info[sig] = Tuple{LineNumberNode,Expr}[])
418+
locdefs = CodeTracking.invoked_get!(Vector{Tuple{LineNumberNode,Expr}}, CodeTracking.method_info, sig)
420419
newdef = unwrap(methodinfo.exprstack[end])
421420
if newdef !== nothing
422421
if !any(locdef->locdef[1] == ln && isequal(RelocatableExpr(locdef[2]), RelocatableExpr(newdef)), locdefs)
@@ -1083,7 +1082,7 @@ function get_def(method::Method; modified_files=revision_queue)
10831082
# We need to find the right file.
10841083
if method.module == Base || method.module == Core || method.module == Core.Compiler
10851084
@warn "skipping $method to avoid parsing too much code"
1086-
CodeTracking.method_info[method.sig] = missing
1085+
CodeTracking.invoked_setindex!(CodeTracking.method_info, method.sig, missing)
10871086
return false
10881087
end
10891088
parentfile, included_files = modulefiles(method.module)
@@ -1102,7 +1101,7 @@ function get_def(method::Method; modified_files=revision_queue)
11021101
end
11031102
@warn "$(method.sig) was not found"
11041103
# So that we don't call it again, store missingness info in CodeTracking
1105-
CodeTracking.method_info[method.sig] = missing
1104+
CodeTracking.invoked_setindex!(CodeTracking.method_info, method.sig, missing)
11061105
return false
11071106
end
11081107

0 commit comments

Comments
 (0)