Skip to content

occurrences: Replace machinery-ref heuristics with JL's synthetic_ref#646

Open
aviatesk wants to merge 1 commit into
masterfrom
avi/occurrence-analysis-refactoring
Open

occurrences: Replace machinery-ref heuristics with JL's synthetic_ref#646
aviatesk wants to merge 1 commit into
masterfrom
avi/occurrence-analysis-refactoring

Conversation

@aviatesk

Copy link
Copy Markdown
Owner

JuliaLowering now tags machinery references (function self-refs inside K"method" / K"function_type" / K"removable", kwsorter body forwards, optional-positional self-forwarding stubs, type self-refs in _typebody! / _equiv_typedef calls, etc.) with :synthetic_ref metadata. Replace the JETLS-side heuristic layer that approximated this with a single metadata check when recording :use occurrences.

Removed: the SkipRecording byte-range map, the
K"block" [K"function_decl" …] traversal that registered ranges, is_selffunc / is_kwsorter_func / kwerr arg-skipping, and the struct-name :local rhs-pattern check. Net ~130 lines out of occurrence-analysis.jl.

Also tighten the :local (mod=nothing):global alias merge for type definitions to discriminate by declaration byte_range rather than by is_internal + name, so an unrelated local Foo / let Foo = 1 sharing a name is not merged.

Regression coverage in test/analysis/test_occurrence_analysis.jl: function / macro / type definitions produce no spurious :use of their own name, and user-written refs inside machinery positions (self-recursive calls, dependent defaults in optional / keyword args and inner constructors) are still counted correctly.

@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.27%. Comparing base (e5d3c5f) to head (87f0059).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #646      +/-   ##
==========================================
- Coverage   75.39%   75.27%   -0.12%     
==========================================
  Files          58       58              
  Lines       10915    10865      -50     
==========================================
- Hits         8229     8179      -50     
  Misses       2686     2686              
Flag Coverage Δ
JETLS.jl 75.27% <100.00%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aviatesk
aviatesk force-pushed the avi/occurrence-analysis-refactoring branch 3 times, most recently from 11f19ff to e4228c6 Compare April 29, 2026 06:18
@aviatesk
aviatesk force-pushed the avi/occurrence-analysis-refactoring branch from e4228c6 to 92d656c Compare May 2, 2026 13:31
@aviatesk
aviatesk force-pushed the avi/occurrence-analysis-refactoring branch 4 times, most recently from a296daf to 29dc2fc Compare May 15, 2026 17:03
JuliaLowering now tags machinery references (function self-refs
inside `K"method"` / `K"function_type"` / `K"removable"`, kwsorter
body forwards, optional-positional self-forwarding stubs, type
self-refs in `_typebody!` / `_equiv_typedef` calls, etc.) with
`:synthetic_ref` metadata. Replace the JETLS-side heuristic layer
that approximated this with a single metadata check when recording
`:use` occurrences.

Removed: the `SkipRecording` byte-range map, the
`K"block" [K"function_decl" …]` traversal that registered ranges,
`is_selffunc` / `is_kwsorter_func` / `kwerr` arg-skipping, and the
struct-name `:local` rhs-pattern check. Net ~130 lines out of
`occurrence-analysis.jl`.

Also tighten the `:local (mod=nothing)` → `:global` alias merge for type
definitions to discriminate by declaration `byte_range` rather than
by `is_internal` + name, so an unrelated `local Foo` / `let Foo = 1`
sharing a name is not merged.

Regression coverage in `test/analysis/test_occurrence_analysis.jl`:
function / macro / type definitions produce no spurious `:use` of
their own name, and user-written refs inside machinery positions
(self-recursive calls, dependent defaults in optional / keyword args
and inner constructors) are still counted correctly.
@aviatesk
aviatesk force-pushed the avi/occurrence-analysis-refactoring branch from 29dc2fc to 87f0059 Compare May 16, 2026 16:27
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