@@ -119,17 +119,22 @@ end
119
119
# In case the line numbers in the source code have changed since the code was compiled,
120
120
# allow packages to set a callback function that corrects them.
121
121
# (Used by Revise and perhaps other packages.)
122
- default_methodloc (method:: Method ) = method. file, method. line
123
- const methodloc_callback = Ref {Function} (default_methodloc)
122
+ const methodloc_callback = Ref {Function} ()
124
123
125
124
# This function does the method location updating
126
- function updated_methodloc (m)
127
- file, line = invokelatest (methodloc_callback[], m)
128
- if file != = nothing && isdefined (@__MODULE__ , :Sys )
125
+ function updated_methodloc (m:: Method ):: Tuple{String, Int32}
126
+ file, line = string (m. file), m. line
127
+ if isassigned (methodloc_callback)
128
+ file, line = try
129
+ invokelatest (methodloc_callback[], m)
130
+ catch
131
+ end
132
+ end
133
+ if isdefined (@__MODULE__ , :Sys ) && Sys. BUILD_STDLIB_PATH != Sys. STDLIB
129
134
# BUILD_STDLIB_PATH gets defined in sysinfo.jl
130
- file = replace (String ( file) , normpath (Sys. BUILD_STDLIB_PATH) => normpath (Sys. STDLIB))
135
+ file = replace (file, normpath (Sys. BUILD_STDLIB_PATH) => normpath (Sys. STDLIB))
131
136
end
132
- return Symbol ( file) , line
137
+ return file, line
133
138
end
134
139
135
140
functionloc (m:: Core.MethodInstance ) = functionloc (m. def)
@@ -205,10 +210,7 @@ function show(io::IO, m::Method)
205
210
show_method_params (io, tv)
206
211
print (io, " in " , m. module)
207
212
if line > 0
208
- try
209
- file, line = updated_methodloc (m)
210
- catch
211
- end
213
+ file, line = updated_methodloc (m)
212
214
print (io, " at " , file, " :" , line)
213
215
end
214
216
end
@@ -257,11 +259,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
257
259
println (io)
258
260
print (io, " [$(n) ] " )
259
261
show (io, meth)
260
- file, line = meth. file, meth. line
261
- try
262
- file, line = updated_methodloc (m)
263
- catch
264
- end
262
+ file, line = updated_methodloc (m)
265
263
push! (LAST_SHOWN_LINE_INFOS, (string (file), line))
266
264
else
267
265
rest += 1
@@ -371,10 +369,7 @@ function show(io::IO, ::MIME"text/html", m::Method)
371
369
end
372
370
print (io, " in " , m. module)
373
371
if line > 0
374
- try
375
- file, line = updated_methodloc (m)
376
- catch
377
- end
372
+ file, line = updated_methodloc (m)
378
373
u = url (m)
379
374
if isempty (u)
380
375
print (io, " at " , file, " :" , line)
@@ -408,11 +403,7 @@ function show(io::IO, mime::MIME"text/plain", mt::AbstractVector{Method})
408
403
first = false
409
404
print (io, " [$(i) ] " )
410
405
show (io, m)
411
- file, line = m. file, m. line
412
- try
413
- file, line = updated_methodloc (m)
414
- catch
415
- end
406
+ file, line = updated_methodloc (m)
416
407
push! (LAST_SHOWN_LINE_INFOS, (string (file), line))
417
408
end
418
409
end
0 commit comments