Skip to content

Commit 29dac94

Browse files
committed
fixups
1 parent 4c98ae0 commit 29dac94

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

base/methodshow.jl

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,22 @@ end
119119
# In case the line numbers in the source code have changed since the code was compiled,
120120
# allow packages to set a callback function that corrects them.
121121
# (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}()
124123

125124
# 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
129134
# 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))
131136
end
132-
return Symbol(file), line
137+
return file, line
133138
end
134139

135140
functionloc(m::Core.MethodInstance) = functionloc(m.def)
@@ -205,10 +210,7 @@ function show(io::IO, m::Method)
205210
show_method_params(io, tv)
206211
print(io, " in ", m.module)
207212
if line > 0
208-
try
209-
file, line = updated_methodloc(m)
210-
catch
211-
end
213+
file, line = updated_methodloc(m)
212214
print(io, " at ", file, ":", line)
213215
end
214216
end
@@ -257,11 +259,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
257259
println(io)
258260
print(io, "[$(n)] ")
259261
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)
265263
push!(LAST_SHOWN_LINE_INFOS, (string(file), line))
266264
else
267265
rest += 1
@@ -371,10 +369,7 @@ function show(io::IO, ::MIME"text/html", m::Method)
371369
end
372370
print(io, " in ", m.module)
373371
if line > 0
374-
try
375-
file, line = updated_methodloc(m)
376-
catch
377-
end
372+
file, line = updated_methodloc(m)
378373
u = url(m)
379374
if isempty(u)
380375
print(io, " at ", file, ":", line)
@@ -408,11 +403,7 @@ function show(io::IO, mime::MIME"text/plain", mt::AbstractVector{Method})
408403
first = false
409404
print(io, "[$(i)] ")
410405
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)
416407
push!(LAST_SHOWN_LINE_INFOS, (string(file), line))
417408
end
418409
end

0 commit comments

Comments
 (0)