Fix generated code ordering with transitive Instantiator captures#196
Merged
Fix generated code ordering with transitive Instantiator captures#196
Conversation
When a root @INSTANTIABLE has both an @Instantiated service and an @Instantiated Instantiator<ChildVC> where the child transitively depends on the service via @received(onlyIfAvailable: true), the generated code placed the Instantiator closure before the service variable declaration, causing a Swift compiler error: closure captures 'service' before it is declared. The topological sort in orderedPropertiesToGenerate now intersects unfulfilled scope keys with both received properties and their unwrapped variants, correctly detecting transitive optional dependencies. The now-redundant onlyIfAvailableUnwrappedReceivedProperties computed property has been removed. Bumps podspec to 1.5.2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mark the scope as fulfilled in the map before recursing into dependencies, preventing cycles when two sibling scopes each have optional received properties that unwrap to each other's property type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #196 +/- ##
=======================================
Coverage 99.90% 99.90%
=======================================
Files 32 32
Lines 3264 3274 +10
=======================================
+ Hits 3261 3271 +10
Misses 3 3
🚀 New features to boost your workflow:
|
Instead of unwrapping all optional received properties (which could create false dependencies for regular @received optional properties), propagate onlyIfAvailable unwrapped properties transitively through the scope tree, mirroring how receivedProperties propagates. Co-Authored-By: Claude Opus 4.6 <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
orderedPropertiesToGenerateto detect transitive optional dependencies by intersecting unfulfilled scope keys with both received properties and their unwrapped variantsonlyIfAvailableUnwrappedReceivedPropertiescomputed propertyFixes #195
Test plan
run_writesConvenienceExtensionOnRootOfTree_whenInstantiatorClosureTransitivelyCapturesVariableDeclaredLaterAlphabeticallypasses🤖 Generated with Claude Code