Skip to content

fix(transform): preserve transitive class dependencies when inlining - #9766

Closed
proggeramlug wants to merge 2 commits into
PerryTS:mainfrom
proggeramlug:fix/9023-ecs-collection-dispatch
Closed

fix(transform): preserve transitive class dependencies when inlining#9766
proggeramlug wants to merge 2 commits into
PerryTS:mainfrom
proggeramlug:fix/9023-ecs-collection-dispatch

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Cross-module inlining copied getEntityReferences and trackEntityReference into consumers that imported only those helpers. Their new MultiMap() expressions lost the defining module’s imported-class metadata and compiled as empty ordinary objects, causing both next is not a function and add is not a function.

Include imported class bindings in the existing source-module dependency checks for free functions and methods. Check parameter defaults and nested thunks as well as function bodies, and recognize namespace-qualified class names. Keep affected calls in their source module; unrelated helper inlining remains eligible.

Validation:

  • Reproduced all three reported failures on clean main: codehz/ecs v0.13.0 comprehensive suite 4/7 passed; Node 7/7 passed. With this change, Perry 7/7 passed, with every upstream case enabled and its assertions/timing thresholds unchanged.
  • Two new Node-parity fixtures pass: transitive generic Map/Set collection and iteration; default imports, parameter defaults, thunks, factory methods, and a same-named consumer class.
  • Transform unit regression covers named aliases, default imports, namespace imports, method candidates, defaults, and an unrelated helper that stays eligible.
  • Final unit suites: transform 125 passed, HIR 382 passed / 1 ignored, codegen 1,410 passed / 1 ignored, runtime 3,137 passed / 4 ignored.
  • Three existing inlining/anonymous-shape parity fixtures pass; pre-tag-check.sh --quick and diff checks pass.
  • Canonical test_affected_crates.sh --base origin/main: runtime passes; compiler CLI has 1,083 passed and the existing PERRY_CONCAT_SITE_CACHE cache-registry failure (fixed separately in fix(cache): register concat switch and explain codegen inputs #9748). The runner stops there; the affected transform/HIR/codegen suites above were also run separately.

No version bump.

Closes #9023.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed cross-module code handling when functions or methods depend on imported classes.
    • Preserved class constructors, methods, iterators, and default-parameter behavior across module boundaries.
    • Resolved failures affecting class collections and transitive class defaults.
  • Tests

    • Added coverage for imported class dependencies, named/default/namespace imports, iterator behavior, and default values.
    • Added regression scenarios for creating, retrieving, and updating grouped collections.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 324a6a3d-0cb0-4b67-8dcc-20e92816f10b

📥 Commits

Reviewing files that changed from the base of the PR and between 12efed1 and bfff1ad.

📒 Files selected for processing (9)
  • changelog.d/9766-transitive-class-inlining.md
  • crates/perry-transform/src/inline/cross_module.rs
  • crates/perry-transform/src/inline/mod.rs
  • test-files/fixtures/issue_9023/bag.ts
  • test-files/fixtures/issue_9023/defaults.ts
  • test-files/fixtures/issue_9023/helpers.ts
  • test-files/fixtures/issue_9023/token.ts
  • test-files/test_parity_9023_transitive_class_collections.ts
  • test-files/test_parity_9023_transitive_class_defaults.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

Cross-module inlining now detects imported class dependencies in function bodies, parameter defaults, closures, and namespace-qualified references. New unit tests and issue 9023 fixtures cover imported constructors, collections, iterators, and default arguments.

Changes

Transitive Class Inlining

Layer / File(s) Summary
Imported class reference detection
crates/perry-transform/src/inline/cross_module.rs
Imported bindings now seed class dependency checks. Function and method harvesting examines bodies, parameter defaults, closures, and namespace-qualified references.
Inlining safety regression tests
crates/perry-transform/src/inline/mod.rs
Tests cover named, default, and namespace imports for functions and methods. They also verify parameter-default handling and unrelated helper eligibility.
Issue 9023 fixture coverage
test-files/fixtures/issue_9023/*, test-files/test_parity_9023_transitive_class_*.ts, changelog.d/9766-transitive-class-inlining.md
Fixtures and parity tests cover imported token defaults, bag mutation, iteration, and tracked values. The changelog records the fix.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to bfff1

The imported-class inlining fix and its regression coverage are consistent, with no actionable merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 8 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving transitive class dependencies during cross-module inlining.
Description check ✅ Passed The description provides a clear summary, implementation details, related issue, validation results, known test limitation, and confirmation that no version bump was included. It does not use every te…
Linked Issues check ✅ Passed The changes directly address issue #9023 by preserving imported class dependencies during inlining, covering function bodies, parameter defaults, nested thunks, methods, and namespace-qualified refere…
Out of Scope Changes check ✅ Passed The changelog entry, transform changes, regression tests, and issue-specific fixtures all support the linked issue and the stated inlining fix. No unrelated code changes are identified.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 8 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main via merge train #9798 (rebase-merged, so your commits keep their authorship). Thanks!

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.

Three codehz/ecs perf-suite tests fail: iterator/collection method lost through wrapped types (next/add "is not a function")

1 participant