@@ -54,13 +54,25 @@ function categorize_stmt(@nospecialize(stmt))
54
54
ismeth, haseval, isinclude, isnamespace, istoplevel = false , false , false , false , false
55
55
if isa (stmt, Expr)
56
56
haseval = matches_eval (stmt)
57
- ismeth = stmt. head === :method
57
+ ismeth = stmt. head === :method || (stmt . head === :thunk && defines_function ( only (stmt . args)))
58
58
istoplevel = stmt. head === :toplevel
59
59
isnamespace = stmt. head === :export || stmt. head === :import || stmt. head === :using
60
60
isinclude = stmt. head === :call && stmt. args[1 ] === :include
61
61
end
62
62
return ismeth, haseval, isinclude, isnamespace, istoplevel
63
63
end
64
+ # Check for thunks that define functions (fixes #792)
65
+ function defines_function (ci)
66
+ isa (ci, CodeInfo) || return false
67
+ if length (ci. code) == 1
68
+ stmt = ci. code[1 ]
69
+ if isa (stmt, Core. ReturnNode)
70
+ val = stmt. val
71
+ isexpr (val, :method ) && return true
72
+ end
73
+ end
74
+ return false
75
+ end
64
76
65
77
"""
66
78
isrequired, evalassign = minimal_evaluation!([predicate,] methodinfo, src::Core.CodeInfo, mode::Symbol)
@@ -280,6 +292,9 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, fra
280
292
end
281
293
isassign (frame, pc) && assign_this! (frame, value)
282
294
pc = next_or_nothing! (frame)
295
+ elseif head === :thunk && defines_function (only (stmt. args))
296
+ mode != = :sigs && Core. eval (mod, stmt)
297
+ pc = next_or_nothing! (frame)
283
298
# elseif head === :thunk && isanonymous_typedef(stmt.args[1])
284
299
# # Anonymous functions should just be defined anew, since there does not seem to be a practical
285
300
# # way to find them within the already-defined module.
@@ -300,7 +315,7 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, fra
300
315
add_signature! (methodinfo, sig, lnn)
301
316
end
302
317
end
303
- pc += 1
318
+ pc = next_or_nothing! (frame)
304
319
else
305
320
pc, pc3 = ret
306
321
# Get the line number from the body
0 commit comments