-
Notifications
You must be signed in to change notification settings - Fork 164
Prefer #if compiler over #if swift
#377
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
Prefer #if compiler over #if swift
#377
Conversation
|
@jflan-dd Thanks for looking into this! Did you change every If the former, my worry is that this may introduce unintended changes where If you do believe all of these changes are appropriate, could you comment on each |
| } | ||
|
|
||
| #if swift(>=6) | ||
| #if compiler(>=6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#isolation default argument.
https://github.com/swiftlang/swift-evolution/blob/main/proposals/0420-inheritance-of-actor-isolation.md
Swift 6 compiler feature without upcoming feature flag
| import Testing | ||
|
|
||
| #if swift(>=6.1) | ||
| #if compiler(>=6.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestScoping ships with Swift Testing in Swift 6.1 compiler
| @@ -1,4 +1,4 @@ | |||
| #if swift(<6) | |||
| #if compiler(<6) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is for the sendability of key paths and should probably go back to swift or enable the specific upcoming feature flag: https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/sourcecompatibility#Inferring-Sendable-for-methods-and-key-path-literals
|
@stephencelis I commented on the changes in I built and ran tests after deleting the The instances in |
| } | ||
|
|
||
| #if swift(>=6) | ||
| #if compiler(>=6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also #isolation
|
@stephencelis Do the updated comments make sense? |
|
@jflan-dd Yup! Just lost track of this, sorry 😄 For the key path sendability, want to add the feature flag to the Swift 5 package.swift and see if that helps things? |
|
@stephencelis I spent a while experimenting with this and I think the current PR implementation is the most correct, although in the vanilla all-SPM case it's all moot. When using SPM natively the existence of the It's only through using something like Bazel that this package could be compiled with the Swift 6 compiler in Swift 5 language mode. I've raised an issue on In this specific case updating the Swift 5 Package.swift file to add the extra flag wouldn't matter because the Bazel build definition files are created using the Swift 6 compiler to extract the package descriptions, so the |
|
@stephencelis I still believe this change is the more correct way to declare these conditionals, but also merged a change to the Bazel rules that we're using to import SPM packages to correctly honor Swift language mode based on |
|
@jflan-dd Thanks for this! All good to go! |
I ran into a compiler error when compiling this package using the Swift 6.1 compiler in Swift 5 language mode.
The specific error I hit was caused by the mismatch between
#if swift(>=6.1)check on_DependencyTraitand theif compiler(<6.1)check aroundtestValuesByTestID.That resulted in not being able to compile the following code with the Swift 6.1 compiler in Swift 5 language mode because
testValuesByTestIDwasn't defined.We're using Bazel to depend on this package, which is how we're hitting this issue, but you can replicate it with SPM by running
swift test -Xswiftc -swift-version -Xswiftc 5in this repo.I updated every instance of
#if swiftto#if compilerin this PR and had passing tests with bothswift testandswift test -Xswiftc -swift-version -Xswiftc 5