@@ -14,11 +14,11 @@ export signature, rename_framemethods!, methoddef!, methoddefs!, bodymethod
14
14
15
15
Returns `true` is `stmt` is a call expression to `name`.
16
16
"""
17
- function iscallto (stmt, name)
17
+ function iscallto (@nospecialize ( stmt) , name)
18
18
if isexpr (stmt, :call )
19
19
a = stmt. args[1 ]
20
- a == name && return true
21
- return is_global_ref (a, Core, :_apply ) && stmt. args[2 ] == name
20
+ a === name && return true
21
+ return is_global_ref (a, Core, :_apply ) && stmt. args[2 ] === name
22
22
end
23
23
return false
24
24
end
28
28
29
29
Returns the function (or Symbol) being called in a :call expression.
30
30
"""
31
- function getcallee (stmt)
31
+ function getcallee (@nospecialize ( stmt) )
32
32
if isexpr (stmt, :call )
33
33
a = stmt. args[1 ]
34
34
is_global_ref (a, Core, :_apply ) && return stmt. args[2 ]
149
149
signature (@nospecialize (recurse), frame:: Frame , pc) = signature (recurse, frame, pc_expr (frame, pc), pc)
150
150
signature (frame:: Frame , pc) = signature (finish_and_return!, frame, pc)
151
151
152
- function minid (node, stmts, id)
152
+ function minid (@nospecialize ( node) , stmts, id)
153
153
if isa (node, SSAValue)
154
154
id = min (id, node. id)
155
155
stmt = stmts[node. id]
@@ -162,7 +162,7 @@ function minid(node, stmts, id)
162
162
return id
163
163
end
164
164
165
- function signature_top (frame, stmt, pc)
165
+ function signature_top (frame, stmt:: Expr , pc)
166
166
@assert ismethod3 (stmt)
167
167
return minid (stmt. args[2 ], frame. framecode. src. code, pc)
168
168
end
@@ -185,7 +185,7 @@ function isanonymous_typedef(src::CodeInfo)
185
185
end
186
186
end
187
187
188
- function define_anonymous (@nospecialize (recurse), frame, stmt)
188
+ function define_anonymous (@nospecialize (recurse), frame, @nospecialize ( stmt) )
189
189
while ! isexpr (stmt, :method )
190
190
pc = step_expr! (recurse, frame, stmt, true )
191
191
stmt = pc_expr (frame, pc)
@@ -248,7 +248,7 @@ function identify_framemethod_calls(frame)
248
248
end
249
249
end
250
250
elseif ismethod1 (stmt)
251
- key = stmt. args[1 ]
251
+ key = stmt. args[1 ]:: Symbol
252
252
mi = get (methodinfos, key, nothing )
253
253
if mi === nothing
254
254
methodinfos[key] = MethodInfo (i)
@@ -268,12 +268,14 @@ function identify_framemethod_calls(frame)
268
268
for (j, mstmt) in enumerate (msrc. code)
269
269
if isexpr (mstmt, :call )
270
270
mkey = mstmt. args[1 ]
271
- isa (key, Expr) && @show mkey
272
- haskey (methodinfos, mkey) && push! (selfcalls, (linetop= i, linebody= j, callee= mkey, caller= key))
271
+ if isa (mkey, Symbol)
272
+ # Could be a GlobalRef but then it's outside frame
273
+ haskey (methodinfos, mkey) && push! (selfcalls, (linetop= i, linebody= j, callee= mkey, caller= key))
274
+ end
273
275
elseif isexpr (mstmt, :meta ) && mstmt. args[1 ] == :generated
274
276
newex = mstmt. args[2 ]
275
277
if isexpr (newex, :new ) && length (newex. args) >= 2 && is_global_ref (newex. args[1 ], Core, :GeneratedFunctionStub )
276
- mkey = newex. args[2 ]
278
+ mkey = newex. args[2 ]:: Symbol
277
279
haskey (methodinfos, mkey) && push! (selfcalls, (linetop= i, linebody= j, callee= mkey, caller= key))
278
280
end
279
281
end
@@ -391,7 +393,7 @@ function find_corrected_name(@nospecialize(recurse), frame, pc, name, parentname
391
393
stmt = pc_expr (frame, pc)
392
394
end
393
395
body = stmt. args[3 ]
394
- if stmt. args[1 ] != name && isa (body, SSAValue)
396
+ if stmt. args[1 ] != = name && isa (body, SSAValue)
395
397
# OK, we can't skip all the stuff that might define the body
396
398
# See https://github.com/timholy/Revise.jl/issues/398
397
399
pc = pc0
@@ -403,10 +405,10 @@ function find_corrected_name(@nospecialize(recurse), frame, pc, name, parentname
403
405
end
404
406
body = @lookup (frame, stmt. args[3 ])
405
407
end
406
- if stmt. args[1 ] != name && isa (body, CodeInfo)
408
+ if stmt. args[1 ] != = name && isa (body, CodeInfo)
407
409
# This might be the GeneratedFunctionStub for a @generated method
408
410
for (i, bodystmt) in enumerate (body. code)
409
- if isexpr (bodystmt, :meta ) && bodystmt. args[1 ] == :generated
411
+ if isexpr (bodystmt, :meta ) && bodystmt. args[1 ] === :generated
410
412
return signature_top (frame, stmt, pc), true
411
413
end
412
414
i >= 5 && break # we should find this early
@@ -529,7 +531,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
529
531
end
530
532
if isa (meth, Method)
531
533
push! (signatures, meth. sig)
532
- elseif stmt. args[1 ] == false
534
+ elseif stmt. args[1 ] === false
533
535
# If it's anonymous and not defined, define it
534
536
pc = step_expr! (recurse, frame, stmt, true )
535
537
meth = whichtt (sigt)
@@ -553,6 +555,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
553
555
if isa (name, Bool)
554
556
error (" not valid for anonymous methods" )
555
557
end
558
+ name = name:: Symbol
556
559
while true # methods containing inner methods may need multiple trips through this loop
557
560
sigt, pc = signature (recurse, frame, stmt, pc)
558
561
stmt = pc_expr (frame, pc)
@@ -570,7 +573,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
570
573
pc = define ? step_expr! (recurse, frame, stmt, true ) : next_or_nothing! (frame)
571
574
meth = whichtt (sigt)
572
575
isa (meth, Method) && push! (signatures, meth. sig) # inner methods are not visible
573
- name == name3 && return pc, pc3 # if this was an inner method we should keep going
576
+ name === name3 && return pc, pc3 # if this was an inner method we should keep going
574
577
stmt = pc_expr (frame, pc) # there *should* be more statements in this frame
575
578
end
576
579
end
@@ -614,7 +617,7 @@ function _methoddefs!(@nospecialize(recurse), signatures, frame::Frame, pc; defi
614
617
return pc
615
618
end
616
619
617
- function is_self_call (stmt, slotnames, argno= 1 )
620
+ function is_self_call (@nospecialize ( stmt) , slotnames, argno= 1 )
618
621
if isa (stmt, Expr)
619
622
if stmt. head == :call
620
623
a = stmt. args[argno]
0 commit comments