Skip to content

🍒 [5.7] Use AbstractStorageDecl::isSettableInSwift to prohibit direct writes to optional requirements #42490

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

Merged

Conversation

AnthonyLatsis
Copy link
Collaborator

  • Description: Stop pretending that an optional requirement is immutable via the StorageImplInfo request. This approach has lead astray the conformance checker and might have had a negative impact on other code paths that expect isSettable or supportsMutation to mean "has a setter". Also, this does not work for imported foreign declarations, since they bypass the request. Instead, use a forwarding AbstractStorageDecl::isSettableInSwift method that special-cases optional requirements. This is a follow-up fix for a regression caused by 🍒 [5.7] CS: optional storage key path components are read-only #42384.
  • Scope: Key path optional storage components.
  • Risk: Low.
  • Reviewers: @jckarter
  • Testing: Test coverage for imported Objective-C protocols and a regression test to ensure that an optional property requirement cannot be witnessed by a get-only property.
  • Original PR: Use AbstractStorageDecl::isSettableInSwift to prohibit direct writes to optional requirements #42455

…s to `optional` requirements

Stop pretending that an optional requirement is immutable via the `StorageImplInfo` request.
This approach has lead astray the conformance checker and might have had a negative impact
on other code paths that expect `isSettable` or `supportsMutation` to mean "has a setter".
Also, this does not work for imported foreign declarations, since they bypass the request.
Instead, use a forwarding `AbstractStorageDecl::isSettableInSwift` method that special-cases
optional requirements. This is a follow-up fix for a regression caused by swiftlang#42384.
@AnthonyLatsis AnthonyLatsis requested a review from a team as a code owner April 20, 2022 18:59
@jckarter
Copy link
Contributor

@swift-ci Please test

@jckarter jckarter merged commit 52a246d into swiftlang:release/5.7 Apr 21, 2022
@AnthonyLatsis AnthonyLatsis deleted the 5.7-objc-optional-keypath-fix branch April 21, 2022 08:11
aschwaighofer pushed a commit to aschwaighofer/swift that referenced this pull request May 10, 2022
…al-keypath-fix

🍒 [5.7-04182022] Use `AbstractStorageDecl::isSettableInSwift` to prohibit direct writes to `optional` requirements
aschwaighofer added a commit that referenced this pull request May 10, 2022
…al-keypath-fix

Merge pull request #42490 from AnthonyLatsis/5.7-objc-optional-keypath-fix
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.7 labels Jan 9, 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.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants