-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.9] Eliminate Observable circular reference errors via lazier TypeRefinementContext building #67689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.9] Eliminate Observable circular reference errors via lazier TypeRefinementContext building #67689
Conversation
DougGregor
commented
Aug 2, 2023
- Explanation: Eager expansion of type refinement contexts (TRCs) for variables within pattern binding declarations is causing cyclic references in some places involving macros. Make this expansion lazy, triggered by walking into these pattern binding declarations as part of availability queries. Also be careful to avoid "has property wrapper" queries as part of building the type refinement context, because they tend to cause circularities.
- Scope: Moderate. All Swift code uses type refinement contexts for availability checking.
- Risk: Moderate. This makes an eagerly-computed data structure more lazy, and that data structure is used for all availability checking.
- Reviewed by: @tshortli
- Original pull request: Eliminate Observable circular reference errors via lazier TypeRefinementContext building #67642
- Issue: rdar://112079160
…e info Querying property wrappers involves semantic analysis that can cause cyclic references while building the type refinement context, and it's unnecessary: we need only know that these are custom attributes to incorporate their source ranges. Switch to the simpler/cheaper query. A small part of fixing the cyclic references in rdar://112079160.
Eager expansion of type refinement contexts (TRCs) for variables within pattern binding declarations is causing cyclic references in some places involving macros. Make this expansion lazy, triggered by walking into these pattern binding declarations as part of (e.g.) availability queries. Another step toward fixing the cyclic references in rdar://112079160.
… lazily The check for "has property wrappers" as part of determining whether the layout of a variable is exposed to clients can trigger reference cycles. Push this check later, which eliminates these cycles for types that aren't frozen/fixed-layout. This is a hack, not a real fix, but it eliminates the cyclic references observed in rdar://112079160.
Add a test case for Observable types that are extended from other source files. Prior to the recent changes to make `TypeRefinementContext` more lazy, this would trigger circular references through the `TypeRefinementContextBuilder`. Finishes rdar://112079160.
…lder This state is a holdover from when accessors we stored "alongside" their variable declarations, rather than contained within them. That's no longer the case, so we don't need to track this information any more.
The type refinement context builder had a bunch of logic to try to model type refinement contexts for the first variable declaration that shows up within a pattern binding declaration. Instead, model this more syntactically by creating a type refinement context for the pattern binding declaration itself. This both addresses a regression in the handling of `if #available` within a closure that's part of an initializer, and fixes a bug in the same area where similar code has explicit availability annotations.
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test Windows |
1 similar comment
@swift-ci please test Windows |
@swift-ci please test macOS |
@swift-ci please test Windows |
@swift-ci please test Linux |
1 similar comment
@swift-ci please test Linux |
@swift-ci please test Windows |
@swift-ci please test windows |
@swift-ci please test macOS |
@swift-ci please test source compatibility release |
@swift-ci please test Windows |
@swidt-ci please test Windows |
@swift-ci please test Windows |