-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[4.2] enforce keypath exclusivity as error #16506
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
[4.2] enforce keypath exclusivity as error #16506
Conversation
This flag supports promoting KeyPath access violations to an error in Swift 4+, while building the standard library in Swift 3 mode. This is only necessary as long as the standard library continues to build in Swift 3 mode. Once the standard library build migrates, it can all be ripped out. <rdar://problem/40115738> [Exclusivity] Enforce Keypath access as an error, not a warning in 4.2.
Modify IRGen to emit builtin access markers with an error flag in Swift 3 mode. KeyPath enforcement is required by user code in Swift 4+ mode, but is implemented within the standard library. A [builtin] flag marks the special case for access generated by Builtins so that they are always enforced as an error regardless of the language mode. This is necessary for Swift 4.2 because the standard library continues to build in Swift 3 mode. Once the standard library build migrates, this is all irrelevant. This does not actually affect existing Swift 3 code, since the KeyPath feature wasn't introduced until Swift 4. <rdar://problem/40115738> [Exclusivity] Enforce Keypath access as an error, not a warning in 4.2.
I noticed this during testing, but it has nothing to do with the other changes in this PR. This static violation has always been present as a warning and would continue to be a warning after my changes.
|
@swift-ci test. |
|
LGTM |
|
=== CCC Information === Explanation: All exclusivity violations should be errors in Swift 4.2 Scope of Issue: Code that uses KeyPaths in a way that violates KeyPaths are a Swift 4 language feature. However, it is possible that Origination: Both the KeyPath and exclusivity feature were introduced commit 08e6624 Risk: Swift 3 mode projects that violate exclusivity with KeyPaths Reviewed By: Michael Gottesman Testing: Several unit tests are checked in. We have bots that test the Directions for QA: N/A |
|
rdar://40115738 [Exclusivity] Enforce Keypath access as an error, not a warning in 4.2. |
It turns out that it's necessary to special case exclusivity Builtins and add flags to SIL instructions because of a couple circumstances:
Swift 3 mode exclusivity warnings will continue to be warnings.
The standard library will continue building in Swift 3 mode (for the foreseeable future).