Skip to content

Commit e8242ab

Browse files
committed
Add callback for looking up methods that have not yet populated cache
1 parent 8d00f9f commit e8242ab

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/CodeTracking.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ end
6565
6666
Return an expression that defines `method`.
6767
"""
68-
definition(method::Method, ::Type{Expr}) = get(method_definitions, method.sig, nothing)
68+
function definition(method::Method, ::Type{Expr})
69+
def = get(method_definitions, method.sig, nothing)
70+
if def === nothing
71+
f = method_lookup_callback[]
72+
if f !== nothing
73+
Base.invokelatest(f, method)
74+
end
75+
def = get(method_definitions, method.sig, nothing)
76+
end
77+
return def === nothing ? nothing : copy(def)
78+
end
6979

7080
definition(method::Method) = definition(method, Expr)
7181

src/data.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ const method_locations = IdDict{Type,LineInfoNode}()
3131
const method_definitions = IdDict{Type,Expr}()
3232

3333
const _pkgfiles = Dict{PkgId,PkgFiles}()
34+
35+
const method_lookup_callback = Ref{Any}(nothing)

0 commit comments

Comments
 (0)