Skip to content

Support Core.define_method builtin for method tracking - #2

Closed
Keno wants to merge 2 commits into
masterfrom
kf/define_method
Closed

Support Core.define_method builtin for method tracking#2
Keno wants to merge 2 commits into
masterfrom
kf/define_method

Conversation

@Keno

@Keno Keno commented Jul 21, 2026

Copy link
Copy Markdown
Member

Julia's method-definition refactor introduces the Core.define_method builtin as the lowered form of method definitions (in place of Expr(:method) in the affected lowering paths). This teaches Revise's statement categorization and method tracking to recognize define_method calls, delegating to the LoweredCodeUtils helpers (ismethod/is_define_method_ref/is_define_method_call_4arg) when available, with graceful fallback on older LoweredCodeUtils.

This was staged pending releases of the supporting infrastructure, now available: LoweredCodeUtils 3.8.0 (JuliaDebug/LoweredCodeUtils.jl#160) and JuliaInterpreter ≥ 0.11.4 both ship define_method support.

Independent of #1 (typegroup struct lowering): applies directly on top of v3.16.1, and the two touch disjoint concerns (method definitions vs type definitions).

Test plan: on a typegroup-enabled Julia build (1.14.0-DEV) with released LoweredCodeUtils 3.8.0 and current JuliaInterpreter master, the test-suite failure set of this branch is exactly identical to current master's on the same configuration (the shared failures are master's lack of typegroup struct support, addressed by #1; the union of both PRs previously passed the full suite). The JuliaInterpreter and LoweredCodeUtils suites covering the define_method machinery pass upstream.

🤖 This pull request was written with the assistance of generative AI (the branch commits carry their respective AI co-author trailers; this PR was prepared with Claude Fable 5).

Keno and others added 2 commits July 21, 2026 19:44
Handle the upcoming `Core.define_method` builtin that will replace
`Expr(:method)` in Julia's lowered code (JuliaLang/julia#60099).
The existing `:method` handling is preserved for backward compatibility
with older Julia versions.

Changes:
- Add `is_define_method_ref` helper for `categorize_stmt`
- Update `_methods_by_execution!` to use `LoweredCodeUtils.ismethod()` and
  `methoddef!()` which now handle both `:method` and `define_method` forms
- Handle sigdata lookup for 4-arg `define_method` (sigdata in args[4]
  vs args[2] for `:method`)
- Convert `Core.LineInfoNode` to `LineNumberNode` for line number tracking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Keep the legacy Expr(:method) path when the installed LoweredCodeUtils does not yet provide Core.define_method helpers. Delegate to the new APIs when available so Revise remains independently testable while preserving support for the upcoming lowering.

CI: https://github.com/timholy/Revise.jl/actions/runs/29064509581

Co-authored-by: OpenAI Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant