Skip to content

Commit 90cd87a

Browse files
authored
Add test with Swift 5 enabling upcoming features (#156)
* Test upcoming features * Fix up for concurrency issues with upcoming features in Swift5
1 parent 77485a9 commit 90cd87a

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

.github/workflows/test.yml

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ jobs:
4545
- name: Test example tvOS
4646
run: scripts/test.sh example-cross-platform tvos
4747

48+
upcoming_feature:
49+
name: Upcoming features
50+
runs-on: macos-14
51+
env:
52+
DEVELOPER_DIR: /Applications/Xcode_15.4.app
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Test with upcoming features
56+
run: ENABLE_UPCOMING_FEATURES=1 scripts/test.sh library ios
57+
4858
benchmark:
4959
name: Benchmark
5060
runs-on: macos-14

Package@swift-5.swift

+18-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
import PackageDescription
44

5+
let swiftSettings: [SwiftSetting]
6+
7+
if Context.environment["ENABLE_UPCOMING_FEATURES"] != nil {
8+
swiftSettings = [
9+
.enableUpcomingFeature("ExistentialAny"),
10+
.enableUpcomingFeature("DisableOutwardActorInference"),
11+
]
12+
}
13+
else {
14+
swiftSettings = [
15+
.enableUpcomingFeature("ExistentialAny"),
16+
]
17+
}
18+
519
let package = Package(
620
name: "swiftui-atom-properties",
721
platforms: [
@@ -15,11 +29,13 @@ let package = Package(
1529
],
1630
targets: [
1731
.target(
18-
name: "Atoms"
32+
name: "Atoms",
33+
swiftSettings: swiftSettings
1934
),
2035
.testTarget(
2136
name: "AtomsTests",
22-
dependencies: ["Atoms"]
37+
dependencies: ["Atoms"],
38+
swiftSettings: swiftSettings
2339
),
2440
],
2541
swiftLanguageVersions: [.v5]

Sources/Atoms/AsyncPhase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public enum AsyncPhase<Success, Failure: Error> {
4949
/// returned value as a success, or thrown error as a failure.
5050
///
5151
/// - Parameter body: A async throwing closure to evaluate.
52-
public init(catching body: @Sendable () async throws -> Success) async where Failure == Error {
52+
public init(catching body: @Sendable () async throws -> Success) async where Failure == any Error {
5353
do {
5454
let value = try await body()
5555
self = .success(value)

Sources/Atoms/Core/SubscriberState.swift

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ internal final class SubscriberState {
3434
_modify { yield &_unsubscribe.value }
3535
}
3636

37+
#if hasFeature(DisableOutwardActorInference)
38+
nonisolated init() {}
39+
#endif
40+
3741
deinit {
3842
if Thread.isMainThread {
3943
_unsubscribe.value?(_subscribing.value)

Sources/Atoms/Suspense.swift

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ private extension Suspense {
206206
}
207207
}
208208

209+
#if !compiler(>=6) && hasFeature(DisableOutwardActorInference)
210+
nonisolated init() {}
211+
#endif
212+
209213
deinit {
210214
suspensionTask?.cancel()
211215
}

scripts/test.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ esac
2424

2525
case $TARGET in
2626
library)
27-
xcodebuild test -scheme swiftui-atom-properties -destination platform="$platform"
27+
xcodebuild clean test -scheme swiftui-atom-properties -destination platform="$platform"
2828
;;
2929
example-ios)
3030
cd Examples/Packages/iOS
31-
xcodebuild test -scheme iOSExamples -destination platform="$platform"
31+
xcodebuild clean test -scheme iOSExamples -destination platform="$platform"
3232
;;
3333
example-cross-platform)
3434
cd Examples/Packages/CrossPlatform
35-
xcodebuild test -scheme CrossPlatformExamples -destination platform="$platform"
35+
xcodebuild clean test -scheme CrossPlatformExamples -destination platform="$platform"
3636
;;
3737
benchmark)
3838
cd Benchmarks
39-
xcodebuild test -scheme BenchmarkTests -destination platform="$platform"
39+
xcodebuild clean test -scheme BenchmarkTests -destination platform="$platform"
4040
;;
4141
esac

0 commit comments

Comments
 (0)