Skip to content

Commit

Permalink
Update on "[compiler] Infer optional dependencies (behind feature flag)"
Browse files Browse the repository at this point in the history
Adds a new feature flag, `enableOptionalDependencies` which when enabled allows PropagateScopeDeps and DeriveMinimalDeps to infer optional dependency paths (`a?.b`). 

In PropagateScopeDeps we look for specific safe patterns of nested optional member expressions:
* `<variable> "." / "?." <property>`
* or `<nested> "." / "?." <property>`

When we find this pattern we record a dependency on the overall chain, so for example in `a?.b.c?.d.map()` we would record a dependency on `a?.b.c?.d` (because the outer `.map()` portion doesn't match the above structure). If the structure doesn't match - for example with `a?.b?.[foo(bar)]?.z` - then we fall back to the existing behavior which treats everything after the initial portion as conditional (for that last example we'd continue to record `a` as the dep).

The other portion is DeriveMinimalDeps, which now represents optional access/dependency states and updates the merge logic to handle them. The order of precedence is unconditional > optional > conditional. 

Note: the flag is off by default, but i tried enabling it for all fixtures and the results were all either unchanged or had correct optional deps inferred. I'll also try running it internally with the flag enabled, but i think we can proceed with review and fix-forward any issues identified from that testing.

[ghstack-poisoned]
  • Loading branch information
josephsavona committed Aug 28, 2024
2 parents bb4e70a + d2b76b8 commit 597c7e7
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 597c7e7

Please sign in to comment.