Skip to content

Commit a18c744

Browse files
committed
rm trackedheads
On recent Julia versions we can just pattern match against `:method` expressions.
1 parent 75242c2 commit a18c744

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/codeedges.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ function direct_links!(cl::CodeLinks, src::CodeInfo)
236236
P = Pair{Union{SSAValue,SlotNumber,GlobalRef},Links}
237237

238238
for (i, stmt) in enumerate(src.code)
239-
if isexpr(stmt, :thunk) && isa(stmt.args[1], CodeInfo)
240-
icl = CodeLinks(cl.thismod, stmt.args[1])
239+
if isexpr(stmt, :thunk) && (arg1 = stmt.args[1]; arg1 isa CodeInfo)
240+
icl = CodeLinks(cl.thismod, arg1)
241241
add_inner!(cl, icl, i)
242242
continue
243-
elseif isa(stmt, Expr) && stmt.head trackedheads
244-
if stmt.head === :method && length(stmt.args) === 3 && isa(stmt.args[3], CodeInfo)
245-
icl = CodeLinks(cl.thismod, stmt.args[3])
243+
elseif isexpr(stmt, :method)
244+
if length(stmt.args) === 3 && (arg3 = stmt.args[3]; arg3 isa CodeInfo)
245+
icl = CodeLinks(cl.thismod, arg3)
246246
add_inner!(cl, icl, i)
247247
end
248248
name = stmt.args[1]

src/packagedef.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ using Base.Meta: isexpr
88

99
const SSAValues = Union{Core.Compiler.SSAValue, JuliaInterpreter.SSAValue}
1010

11-
const trackedheads = (:method,)
1211
const structdecls = (:_structtype, :_abstracttype, :_primitivetype)
1312

1413
export signature, rename_framemethods!, methoddef!, methoddefs!, bodymethod

test/codeedges.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using LoweredCodeUtils: callee_matches, istypedef, exclude_named_typedefs
66
using JuliaInterpreter: is_global_ref, is_quotenode
77
using Test
88

9-
function hastrackedexpr(@nospecialize(stmt); heads=LoweredCodeUtils.trackedheads)
9+
function hastrackedexpr(@nospecialize(stmt))
1010
haseval = false
1111
if isa(stmt, Expr)
1212
if stmt.head === :call
@@ -16,8 +16,8 @@ function hastrackedexpr(@nospecialize(stmt); heads=LoweredCodeUtils.trackedheads
1616
callee_matches(f, Core, :_setsuper!) && return true, haseval
1717
f === :include && return true, haseval
1818
elseif stmt.head === :thunk
19-
any(s->any(hastrackedexpr(s; heads=heads)), stmt.args[1].code) && return true, haseval
20-
elseif stmt.head heads
19+
any(s->any(hastrackedexpr(s)), stmt.args[1].code) && return true, haseval
20+
elseif stmt.head === :method
2121
return true, haseval
2222
end
2323
end

0 commit comments

Comments
 (0)