@@ -42,17 +42,11 @@ function whereis(method::Method)
4242 end
4343 end
4444 if lin === nothing
45- file, line = maybe_fixup_stdlib_path( String(method. file) ), method. line
45+ file, line = String(method. file), method. line
4646 else
4747 file, line = fileline(lin[1 ])
4848 end
49- if ! isabspath(file)
50- # This may be a Base or Core method
51- newfile = Base. find_source_file(file)
52- if isa(newfile, AbstractString)
53- file = normpath(newfile)
54- end
55- end
49+ file = maybe_fix_path(file)
5650 return file, line
5751end
5852
@@ -77,7 +71,21 @@ was compiled. The current location is returned.
7771"""
7872function whereis(lineinfo, method:: Method )
7973 file, line1 = whereis(method)
80- return file, lineinfo. line- method. line+ line1
74+ # We could be in an expanded macro. Apply the correction only if the filename checks out.
75+ # (We're not super-fastidious here because of symlinks and other path ambiguities)
76+ samefile = basename(file) == basename(String(lineinfo. file))
77+ if ! samefile
78+ return maybe_fix_path(String(lineinfo. file)), lineinfo. line
79+ end
80+ return file, lineinfo. line - method. line + line1
81+ end
82+ function whereis(lineinfo:: Core.LineInfoNode , method:: Method )
83+ # With LineInfoNode we have certainty about whether we're in a macro expansion
84+ if lineinfo. method == Symbol(" macro expansion" )
85+ return maybe_fix_path(String(lineinfo. file)), lineinfo. line
86+ end
87+ file, line1 = whereis(method)
88+ return file, lineinfo. line - method. line + line1
8189end
8290
8391"""
0 commit comments