118118default_methodloc (method:: Method ) =  method. file, method. line
119119const  methodloc_callback =  Ref {Function} (default_methodloc)
120120
121+ #  This function does the method location updating
122+ function  updated_methodloc (m)
123+     file, line =  invokelatest (methodloc_callback[], m)
124+     if  file != =  nothing  &&  isdefined (@__MODULE__ , :Sys )
125+         #  BUILD_STDLIB_PATH gets defined in sysinfo.jl
126+         file =  replace (String (file), Sys. BUILD_STDLIB_PATH =>  Sys. STDLIB)
127+     end 
128+     return  Symbol (file), line
129+ end 
130+ 
121131functionloc (m:: Core.MethodInstance ) =  functionloc (m. def)
122132
123133""" 
@@ -126,7 +136,7 @@ functionloc(m::Core.MethodInstance) = functionloc(m.def)
126136Returns a tuple `(filename,line)` giving the location of a `Method` definition. 
127137""" 
128138function  functionloc (m:: Method )
129-     file, ln =  invokelatest (methodloc_callback[],  m)
139+     file, ln =  updated_methodloc ( m)
130140    if  ln <=  0 
131141        error (" could not determine location of method definition"  )
132142    end 
@@ -194,7 +204,7 @@ function show(io::IO, m::Method; kwtype::Union{DataType, Nothing}=nothing)
194204    print (io, "  in "  , m. module)
195205    if  line >  0 
196206        try 
197-             file, line =  invokelatest (methodloc_callback[],  m)
207+             file, line =  updated_methodloc ( m)
198208        catch 
199209        end 
200210        print (io, "  at "  , file, " :"  , line)
@@ -248,7 +258,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
248258            show (io, meth; kwtype= kwtype)
249259            file, line =  meth. file, meth. line
250260            try 
251-                 file, line =  invokelatest (methodloc_callback[], meth )
261+                 file, line =  updated_methodloc (m )
252262            catch 
253263            end 
254264            push! (LAST_SHOWN_LINE_INFOS, (string (file), line))
@@ -363,7 +373,7 @@ function show(io::IO, ::MIME"text/html", m::Method; kwtype::Union{DataType, Noth
363373    print (io, "  in "  , m. module)
364374    if  line >  0 
365375        try 
366-             file, line =  invokelatest (methodloc_callback[],  m)
376+             file, line =  updated_methodloc ( m)
367377        catch 
368378        end 
369379        u =  url (m)
@@ -402,7 +412,7 @@ function show(io::IO, mime::MIME"text/plain", mt::AbstractVector{Method})
402412        show (io, m)
403413        file, line =  m. file, m. line
404414        try 
405-             file, line =  invokelatest (methodloc_callback[],  m)
415+             file, line =  updated_methodloc ( m)
406416        catch 
407417        end 
408418        push! (LAST_SHOWN_LINE_INFOS, (string (file), line))
0 commit comments