Skip to content

Commit bc5d728

Browse files
committed
Improve the method3 analysis, especially for anonymous methods
The most important change here is that this guarantees advancing the pc.
1 parent b218d7a commit bc5d728

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/signatures.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,18 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
442442
framecode, pcin = frame.framecode, pc
443443
if ismethod3(stmt)
444444
pc3 = pc
445-
sigt, pc = signature(recurse, frame, stmt, pc)
446-
if sigt === nothing && define
447-
step_expr!(recurse, frame, stmt, true)
448-
end
445+
arg1 = stmt.args[1]
449446
sigt, pc = signature(recurse, frame, stmt, pc)
450447
meth = whichtt(sigt)
451-
if (meth === nothing || !(meth.sig <: sigt && sigt <: meth.sig)) && define
448+
if isa(meth, Method) && (meth.sig <: sigt && sigt <: meth.sig)
449+
pc = next_or_nothing!(frame)
450+
elseif define
452451
pc = step_expr!(recurse, frame, stmt, true)
453452
meth = whichtt(sigt)
454453
end
455454
if isa(meth, Method)
456455
push!(signatures, meth.sig)
457-
elseif stmt.args[1] === false
456+
elseif arg1 === false || arg1 === nothing
458457
# If it's anonymous and not defined, define it
459458
pc = step_expr!(recurse, frame, stmt, true)
460459
meth = whichtt(sigt)
@@ -471,7 +470,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
471470
end
472471
end
473472
frame.pc = pc
474-
return ( define ? pc : next_or_nothing!(frame) ), pc3
473+
return pc, pc3
475474
end
476475
ismethod1(stmt) || error("expected method opening, got ", stmt)
477476
name = stmt.args[1]

0 commit comments

Comments
 (0)