@@ -387,11 +387,34 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
387
387
error (" not valid for anonymous methods" )
388
388
end
389
389
parentname = get_parentname (name) # e.g., name = #foo#7 and parentname = foo
390
- nextstmt = pc_expr (frame, pc+ 1 )
391
- if ismethod1 (nextstmt)
392
- name = nextstmt. args[1 ]
390
+ pcinc = 1
391
+ nextstmt = pc_expr (frame, pc+ pcinc)
392
+ while ismethod1 (nextstmt) || isexpr (nextstmt, :global )
393
+ if ismethod1 (nextstmt)
394
+ name = nextstmt. args[1 ]
395
+ end
396
+ pcinc += 1
397
+ nextstmt = pc_expr (frame, pc+ pcinc)
398
+ end
399
+ if ! define && String (name)[1 ] == ' #'
400
+ # We will have to correct the name.
401
+ # We can only correct one at a time, so work backwards from a non-gensymmed name
402
+ # (https://github.com/timholy/Revise.jl/issues/290)
403
+ pc0 = pc
404
+ idx1 = findall (ismethod1, frame. framecode. src. code)
405
+ idx1 = idx1[idx1 .>= pc]
406
+ i = length (idx1)
407
+ while i > 1 && ! startswith (String (pc_expr (frame, idx1[i]). args[1 ]), ' #' )
408
+ i -= 1
409
+ end
410
+ while i > 1
411
+ frame. pc = idx1[i]
412
+ methoddef! (recurse, [], frame, frame. pc; define= define)
413
+ i -= 1
414
+ end
415
+ frame. pc = pc0
393
416
end
394
- if name != parentname
417
+ if name != parentname && ! define
395
418
name, endpc = correct_name! (recurse, frame, pc, name, parentname)
396
419
end
397
420
while true # methods containing inner methods may need multiple trips through this loop
0 commit comments