@@ -131,10 +131,14 @@ In this case, `lastpc == pc`.
131
131
If no 3-argument `:method` expression is found, `sigt` will be `nothing`.
132
132
"""
133
133
function signature (@nospecialize (recurse), frame:: Frame , @nospecialize (stmt), pc)
134
+ mod = moduleof (frame)
134
135
lastpc = frame. pc = pc
135
136
while ! isexpr (stmt, :method , 3 ) # wait for the 3-arg version
136
137
if isexpr (stmt, :thunk ) && isanonymous_typedef (stmt. args[1 ])
137
138
lastpc = pc = define_anonymous (recurse, frame, stmt)
139
+ elseif isexpr (stmt, :call ) && JuliaInterpreter. is_quotenode (stmt. args[1 ], Core. Typeof) &&
140
+ (sym = stmt. args[2 ]; isa (sym, Symbol) && ! isdefined (mod, sym))
141
+ return nothing , pc
138
142
else
139
143
lastpc = pc
140
144
pc = step_expr! (recurse, frame, stmt, true )
@@ -278,37 +282,37 @@ function correct_name!(@nospecialize(recurse), frame, pc, name, parentname)
278
282
nameinfo = find_corrected_name (frame, pc, name, parentname)
279
283
if nameinfo === nothing
280
284
pc = skip_until (stmt-> isexpr (stmt, :method , 3 ), frame, pc)
281
- lastidx = pc
282
285
pc = next_or_nothing (frame, pc)
286
+ return name, pc
287
+ end
288
+ pctop, isgen = nameinfo
289
+ sigtparent, lastpcparent = signature (recurse, frame, pctop)
290
+ sigtparent === nothing && return name, pc
291
+ methparent = whichtt (sigtparent)
292
+ methparent === nothing && return name, pc # caller isn't defined, no correction is needed
293
+ if isgen
294
+ cname = nameof (methparent. generator. gen)
283
295
else
284
- pctop, isgen = nameinfo
285
- sigtparent, lastpcparent = signature (recurse, frame, pctop)
286
- methparent = whichtt (sigtparent)
287
- methparent === nothing && return name, pc # caller isn't defined, no correction is needed
288
- if isgen
289
- cname = nameof (methparent. generator. gen)
290
- else
291
- bodyparent = Base. uncompressed_ast (methparent)
292
- bodystmt = bodyparent. code[end - 1 ]
293
- @assert isexpr (bodystmt, :call )
294
- ref = getcallee (bodystmt)
295
- isa (ref, GlobalRef) || @show ref typeof (ref)
296
- @assert isa (ref, GlobalRef)
297
- @assert ref. mod == moduleof (frame)
298
- cname = ref. name
299
- end
300
- # Swap in the correct name
301
- if name != cname
302
- replacename! (frame. framecode. src. code, name=> cname)
303
- end
296
+ bodyparent = Base. uncompressed_ast (methparent)
297
+ bodystmt = bodyparent. code[end - 1 ]
298
+ @assert isexpr (bodystmt, :call )
299
+ ref = getcallee (bodystmt)
300
+ isa (ref, GlobalRef) || @show ref typeof (ref)
301
+ @assert isa (ref, GlobalRef)
302
+ @assert ref. mod == moduleof (frame)
303
+ cname = ref. name
304
+ end
305
+ # Swap in the correct name
306
+ if name != cname
307
+ replacename! (frame. framecode. src. code, name=> cname)
308
+ end
309
+ stmt = pc_expr (frame, lastpcparent)
310
+ while ! ismethod (stmt)
311
+ lastpcparent = next_or_nothing (frame, lastpcparent)
312
+ lastpcparent === nothing && return name, lastpcparent
304
313
stmt = pc_expr (frame, lastpcparent)
305
- while ! ismethod (stmt)
306
- lastpcparent = next_or_nothing (frame, lastpcparent)
307
- lastpcparent === nothing && return name, lastpcparent
308
- stmt = pc_expr (frame, lastpcparent)
309
- end
310
- name = stmt. args[1 ]
311
314
end
315
+ name = stmt. args[1 ]
312
316
return name, pc
313
317
end
314
318
@@ -345,7 +349,15 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
345
349
if ismethod3 (stmt)
346
350
pc3 = pc
347
351
sigt, pc = signature (recurse, frame, stmt, pc)
352
+ if sigt === nothing && define
353
+ step_expr! (recurse, frame, stmt, true )
354
+ end
355
+ sigt, pc = signature (recurse, frame, stmt, pc)
348
356
meth = whichtt (sigt)
357
+ if meth === nothing && define
358
+ step_expr! (recurse, frame, stmt, true )
359
+ meth = whichtt (sigt)
360
+ end
349
361
if isa (meth, Method)
350
362
push! (signatures, meth. sig)
351
363
elseif stmt. args[1 ] == false
0 commit comments