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