Sources: route mock aliases through production topological sort#261
Merged
Sources: route mock aliases through production topological sort#261
Conversation
Unifies mock and production alias emission by treating aliases as first-class tree nodes (`MockTreeItem.alias`) in `collectMockParameterTree`, so they ride the same `orderedPropertiesToGenerate` topological sort that production uses. Replaces the prior surgical interleave (preChild/postChild partition in `emitReceiverBindings`) with a single linear walk over items. Property-only consumers (`SafeDIOverrides` generation, configuration type collection, uncovered-dependency collection, disambiguation) pull property nodes via the new `propertyNodes` helper and skip aliases. Alias items emit a single `let <alias>: <Type> = <fulfilling>` line resolved through `flatParameterDisambiguationMap`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
f6b7da9 to
2e361c2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e361c24f0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Matches the existing createdProperties pattern. Avoids redundant recomputation during tree validation, where requiredReceivedProperties is hammered by the recursive cycle walk and scopes reached from multiple paths paid the cost each visit. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #261 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 6369 6370 +1
=========================================
+ Hits 6369 6370 +1
🚀 New features to boost your workflow:
|
…o-sort-refactor-v2
…ree walk The switch over child scope data had three cases: `.root` (never a child — only the top-level scope is ever rooted), `.alias`, and `.property`. The `.root` case's `continue` body was unreachable, and the `.property` case included a defensive `guard let childProperty = childGenerator.property` whose else branch was also unreachable (the `.property` enum case always carries a non-nil property). Restructuring as an `if case` chain lets the loop silently skip the unreachable `.root` without a dedicated line that coverage tools see as dead. Also inlines `hasAliasChildren` into `requiresFunctionWrapper` — it was only ever called when `needsConfigurationStruct` is false, which implies `propertyChildren.isEmpty`, so checking `!children.isEmpty` is equivalent and drops the dead else branch of its pattern-match closure. Merges the `constructionArguments` extraction into the same `if let` block that collects default parameters, removing an unreachable `?? []` fallback. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MockTreeItem.aliasnodes incollectMockParameterTree, so they ride the sameorderedPropertiesToGeneratetopological sort production uses.preChild/postChildByFulfillingpartition inemitReceiverBindingswith a single linear walk over[MockTreeItem]items.SafeDIOverrides, configuration types, uncovered-dependency collection, disambiguation) pull property nodes via a newpropertyNodeshelper and skip aliases.let <alias>: <Type> = <fulfilling>line resolved throughflatParameterDisambiguationMap.SafeDIOverridesstruct orsafeDIOverridesparameter (hasOverridableTreedistinguishes fromhasTree).Why
Production's topo sort already orders aliases correctly relative to their fulfilling children and to sibling nested-function captures. Mock was filtering to
.property(...)scopes and re-materializing aliases via a preChild/postChild partition that couldn't handle transitive captures from sibling nested funcs. The surgical interleave shipped first; this PR is the deferred architectural unification.Test plan
swift build --traits sourceBuildswift test --traits sourceBuild(all 831 tests pass)./CLI/lint.sh🤖 Generated with Claude Code