Skip to content

Commit afc73a9

Browse files
authored
Support multiple definitions for a particular signature (#59)
Fixes #55
1 parent 0823435 commit afc73a9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CodeTracking"
22
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "0.5.11"
4+
version = "1.0.0"
55

66
[deps]
77
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

src/CodeTracking.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ include("utils.jl")
1919

2020
# These values get populated by Revise
2121

22-
const method_info = IdDict{Type,Union{Missing,Tuple{LineNumberNode,Expr}}}()
22+
# `method_info[sig]` is either:
23+
# - `missing`, to indicate that the method cannot be located
24+
# - a list of `(lnn,ex)` pairs. In almost all cases there will be just one of these,
25+
# but "mistakes" in moving methods from one file to another can result in more than
26+
# definition. The last pair in the list is the currently-active definition.
27+
const method_info = IdDict{Type,Union{Missing,Vector{Tuple{LineNumberNode,Expr}}}}()
2328

2429
const _pkgfiles = Dict{PkgId,PkgFiles}()
2530

@@ -68,7 +73,7 @@ function whereis(method::Method)
6873
end
6974
if lin === nothing || ismissing(lin)
7075
else
71-
file, line = fileline(lin[1])
76+
file, line = fileline(lin[end][1])
7277
end
7378
file = maybe_fix_path(file)
7479
return file, line
@@ -251,7 +256,7 @@ function definition(::Type{Expr}, method::Method)
251256
end
252257
end
253258
end
254-
return def === nothing || ismissing(def) ? nothing : copy(def[2])
259+
return def === nothing || ismissing(def) ? nothing : copy(def[end][2])
255260
end
256261

257262
definition(method::Method) = definition(Expr, method)

0 commit comments

Comments
 (0)