@@ -43,8 +43,7 @@ function signature(@nospecialize(recurse), frame::Frame, @nospecialize(stmt), pc
43
43
while ! isexpr (stmt, :method , 3 ) # wait for the 3-arg version
44
44
if isanonymous_typedef (stmt)
45
45
lastpc = pc = step_through_methoddef (recurse, frame, stmt) # define an anonymous function
46
- elseif isexpr (stmt, :call ) && (q = (stmt:: Expr ). args[1 ]; isa (q, QuoteNode) && q. value === Core. Typeof) &&
47
- (sym = (stmt:: Expr ). args[2 ]; isa (sym, Symbol) && ! isdefined (mod, sym))
46
+ elseif is_Typeof_for_anonymous_methoddef (stmt, frame. framecode. src. code, mod)
48
47
return nothing , pc
49
48
else
50
49
lastpc = pc
61
60
signature (@nospecialize (recurse), frame:: Frame , pc) = signature (recurse, frame, pc_expr (frame, pc), pc)
62
61
signature (frame:: Frame , pc) = signature (finish_and_return!, frame, pc)
63
62
63
+ function is_Typeof_for_anonymous_methoddef (@nospecialize (stmt), code:: Vector{Any} , mod:: Module )
64
+ isexpr (stmt, :call ) || return false
65
+ f = stmt. args[1 ]
66
+ isa (f, QuoteNode) || return false
67
+ f. value === Core. Typeof || return false
68
+ arg1 = stmt. args[2 ]
69
+ if isa (arg1, SSAValue)
70
+ arg1 = code[arg1. id]
71
+ end
72
+ arg1 isa Symbol || return false
73
+ return ! isdefined (mod, arg1)
74
+ end
75
+
64
76
function minid (@nospecialize (node), stmts, id)
65
77
if isa (node, SSAValue)
66
78
id = min (id, node. id)
@@ -262,7 +274,7 @@ function set_to_running_name!(@nospecialize(recurse), replacements, frame, metho
262
274
replacements[callee] = cname
263
275
mi = methodinfos[cname] = methodinfos[callee]
264
276
src = frame. framecode. src
265
- replacename! (src. code[mi. start: mi. stop], callee=> cname) # the method itself
277
+ replacename! (@view ( src. code[mi. start: mi. stop]) , callee=> cname) # the method itself
266
278
for r in mi. refs # the references
267
279
replacename! ((src. code[r]):: Expr , callee=> cname)
268
280
end
365
377
366
378
replacename! (src:: CodeInfo , pr) = replacename! (src. code, pr)
367
379
368
- function replacename! (args:: Vector{Any} , pr)
380
+ function replacename! (args:: AbstractVector , pr)
369
381
oldname, newname = pr
370
382
for i = 1 : length (args)
371
383
a = args[i]
@@ -377,6 +389,9 @@ function replacename!(args::Vector{Any}, pr)
377
389
args[i] = QuoteNode (newname)
378
390
elseif isa (a, Vector{Any})
379
391
replacename! (a, pr)
392
+ elseif isa (a, Core. ReturnNode) && isdefined (a, :val ) && a. val isa Expr
393
+ # there is something like `ReturnNode(Expr(:method, Symbol(...)))`
394
+ replacename! (a. val:: Expr , pr)
380
395
elseif a === oldname
381
396
args[i] = newname
382
397
end
0 commit comments