Skip to content

Conversation

hborla
Copy link
Member

@hborla hborla commented May 17, 2021

Cherry-pick of #37464

  • Explanation: Property wrappers on local variables were new in Swift 5.4, and in Swift 5.5 property wrappers are allowed on parameters as well. This is the first kind of local computed property to have synthesized accessors that capture other variables, rather than accessors that are explicitly written by the programmer. The compiler's implementation of computing and emitting local captures in SILGen relied on accessors being parsed rather than synthesized. So, transitive captures in local property wrapper accessors were not properly emitted when the wrapped variable is captured in a closure, leading to cryptic/bogus compiler errors because the backing property wrapper storage was not captured in the closure. The fix is simply to use synthesized accessors to compute transitive captures for wrapped variables in a local context.
  • Scope: The scope is limited to property wrappers on local variables and parameters that are captured in closures.
  • Risk: Very low.
  • Testing: Added several SILGen tests to exercise capturing local property wrappers and wrapped parameters.
  • Reviewer: @slavapestov

Resolves: rdar://74457878

accessors, use synthesized accessors for wrapped and projected properties.
@hborla hborla added the r5.5 label May 17, 2021
@hborla
Copy link
Member Author

hborla commented May 17, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 8409ac4

@hborla
Copy link
Member Author

hborla commented May 18, 2021

@swift-ci please test Linux platform

@hborla hborla merged commit 19b8928 into swiftlang:release/5.5 May 18, 2021
@hborla hborla deleted the 5.5-local-wrapper-capture branch May 18, 2021 04:32
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.5 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants