Skip to content

Commit 7ac630f

Browse files
authored
Support swift-syntax from 600.0.0-latest (#3160)
* Support swift-syntax from 600.0.0-latest The Xcode 16 beta generates macro projects using these swift-syntax snapshots. Luckily things seem to be backwards compatible, so we can expand our supported range. * wip
1 parent 889c27b commit 7ac630f

File tree

13 files changed

+83
-54
lines changed

13 files changed

+83
-54
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/SyncUps/SyncUps/RecordMeeting.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ struct SpeakerArc: Shape {
346346
}
347347
}
348348

349-
private var degreesPerSpeaker: Double {
349+
nonisolated private var degreesPerSpeaker: Double {
350350
360 / Double(totalSpeakers)
351351
}
352-
private var startAngle: Angle {
352+
nonisolated private var startAngle: Angle {
353353
Angle(degrees: degreesPerSpeaker * Double(speakerIndex) + 1)
354354
}
355-
private var endAngle: Angle {
355+
nonisolated private var endAngle: Angle {
356356
Angle(degrees: startAngle.degrees + degreesPerSpeaker - 1)
357357
}
358358
}

Examples/SyncUps/SyncUpsTests/AppFeatureTests.swift

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ final class AppFeatureTests: XCTestCase {
1919
}
2020

2121
await store.send(\.path[id:0].detail.editButtonTapped) {
22-
$0.path[id: 0]?.detail?.destination = .edit(
23-
SyncUpForm.State(syncUp: syncUp)
24-
)
22+
$0.path[id: 0]?.modify(\.detail) { $0.destination = .edit(SyncUpForm.State(syncUp: syncUp)) }
2523
}
2624

2725
syncUp.title = "Blob"
2826
await store.send(\.path[id:0].detail.destination.edit.binding.syncUp, syncUp) {
29-
$0.path[id: 0]?.detail?.destination?.edit?.syncUp.title = "Blob"
27+
$0.path[id: 0]?.modify(\.detail) {
28+
$0.destination?.modify(\.edit) { $0.syncUp.title = "Blob" }
29+
}
3030
}
3131

3232
await store.send(\.path[id:0].detail.doneEditingButtonTapped) {
33-
$0.path[id: 0]?.detail?.destination = nil
34-
$0.path[id: 0]?.detail?.syncUp.title = "Blob"
33+
$0.path[id: 0]?.modify(\.detail) {
34+
$0.destination = nil
35+
$0.syncUp.title = "Blob"
36+
}
3537
}
3638
.finish()
3739
}
@@ -51,11 +53,11 @@ final class AppFeatureTests: XCTestCase {
5153
}
5254

5355
await store.send(\.path[id:0].detail.deleteButtonTapped) {
54-
$0.path[id: 0]?.detail?.destination = .alert(.deleteSyncUp)
56+
$0.path[id: 0]?.modify(\.detail) { $0.destination = .alert(.deleteSyncUp) }
5557
}
5658

5759
await store.send(\.path[id:0].detail.destination.alert.confirmDeletion) {
58-
$0.path[id: 0, case: \.detail]?.destination = nil
60+
$0.path[id: 0]?.modify(\.detail) { $0.destination = nil }
5961
$0.syncUpsList.syncUps = []
6062
}
6163

@@ -109,13 +111,15 @@ final class AppFeatureTests: XCTestCase {
109111
XCTAssertEqual($0.path.count, 1)
110112
}
111113
store.assert {
112-
$0.path[id: 0]?.detail?.syncUp.meetings = [
113-
Meeting(
114-
id: Meeting.ID(UUID(0)),
115-
date: Date(timeIntervalSince1970: 1_234_567_890),
116-
transcript: "I completed the project"
117-
)
118-
]
114+
$0.path[id: 0]?.modify(\.detail) {
115+
$0.syncUp.meetings = [
116+
Meeting(
117+
id: Meeting.ID(UUID(0)),
118+
date: Date(timeIntervalSince1970: 1_234_567_890),
119+
transcript: "I completed the project"
120+
)
121+
]
122+
}
119123
}
120124
}
121125
}

Examples/SyncUps/SyncUpsTests/SyncUpDetailTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ final class SyncUpDetailTests: XCTestCase {
102102

103103
syncUp.title = "Blob's Meeting"
104104
await store.send(\.destination.edit.binding.syncUp, syncUp) {
105-
$0.destination?.edit?.syncUp.title = "Blob's Meeting"
105+
$0.destination?.modify(\.edit) { $0.syncUp.title = "Blob's Meeting" }
106106
}
107107

108108
await store.send(.doneEditingButtonTapped) {

Examples/SyncUps/SyncUpsTests/SyncUpsListTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class SyncUpsListTests: XCTestCase {
2424

2525
syncUp.title = "Engineering"
2626
await store.send(\.destination.add.binding.syncUp, syncUp) {
27-
$0.destination?.add?.syncUp.title = "Engineering"
27+
$0.destination?.modify(\.add) { $0.syncUp.title = "Engineering" }
2828
}
2929

3030
await store.send(.confirmAddSyncUpButtonTapped) {

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
dependencies: [
2121
.package(url: "https://github.com/apple/swift-collections", from: "1.1.0"),
2222
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
23-
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"511.0.0"),
23+
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"601.0.0"),
2424
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
2525
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.0"),
2626
.package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.3.0"),

Sources/ComposableArchitecture/Internal/NavigationID.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ struct NavigationIDPath: Hashable, Sendable {
3535

3636
struct NavigationID: Hashable, @unchecked Sendable {
3737
private let kind: Kind
38-
private let identifier: AnyHashableSendable?
38+
private let identifier: AnyHashable?
3939
private let tag: UInt32?
4040

41-
enum Kind: Hashable, @unchecked Sendable {
41+
enum Kind: Hashable {
4242
case casePath(root: Any.Type, value: Any.Type)
4343
case keyPath(AnyKeyPath)
4444

@@ -73,7 +73,7 @@ struct NavigationID: Hashable, @unchecked Sendable {
7373
self.kind = .keyPath(keyPath)
7474
self.tag = EnumMetadata(Value.self)?.tag(of: base)
7575
if let id = _identifiableID(base) ?? EnumMetadata.project(base).flatMap(_identifiableID) {
76-
self.identifier = AnyHashableSendable(id)
76+
self.identifier = id
7777
} else {
7878
self.identifier = nil
7979
}
@@ -105,7 +105,7 @@ struct NavigationID: Hashable, @unchecked Sendable {
105105
self.kind = .casePath(root: Root.self, value: Value.self)
106106
self.tag = EnumMetadata(Root.self)?.tag(of: root)
107107
if let id = _identifiableID(root) ?? _identifiableID(value) {
108-
self.identifier = AnyHashableSendable(id)
108+
self.identifier = id
109109
} else {
110110
self.identifier = nil
111111
}

Sources/ComposableArchitecture/Internal/PresentationID.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ extension PresentationState {
66
}
77
}
88

9-
struct PresentationID: Hashable, Identifiable, Sendable {
10-
private let identifier: AnyHashableSendable?
9+
struct PresentationID: Hashable, Identifiable {
10+
private let identifier: AnyHashable?
1111
private let tag: UInt32?
1212
private let type: Any.Type
1313

1414
init<Base>(base: Base) {
1515
self.tag = EnumMetadata(Base.self)?.tag(of: base)
1616
if let id = _identifiableID(base) ?? EnumMetadata.project(base).flatMap(_identifiableID) {
17-
self.identifier = AnyHashableSendable(id)
17+
self.identifier = id
1818
} else {
1919
self.identifier = nil
2020
}

Sources/ComposableArchitecture/Observation/ViewAction.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ public protocol ViewAction<ViewAction> {
1212
public protocol ViewActionSending<StoreState, StoreAction> {
1313
associatedtype StoreState
1414
associatedtype StoreAction: ViewAction
15-
@MainActor(unsafe) var store: Store<StoreState, StoreAction> { get }
15+
#if swift(>=5.10)
16+
@MainActor @preconcurrency var store: Store<StoreState, StoreAction> { get }
17+
#else
18+
@MainActor(unsafe) var store: Store<StoreState, StoreAction> { get }
19+
#endif
1620
}
1721

1822
extension ViewActionSending {

Sources/ComposableArchitectureMacros/Extensions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,15 @@ extension DeclGroupSyntax {
284284
return self.is(StructDeclSyntax.self)
285285
}
286286
}
287+
288+
extension AttributedTypeSyntax {
289+
var isInout: Bool {
290+
#if canImport(SwiftSyntax600)
291+
self.specifiers.contains(
292+
where: { $0.as(SimpleTypeSpecifierSyntax.self)?.specifier.tokenKind == .keyword(.inout) }
293+
) == true
294+
#else
295+
self.specifier?.tokenKind == .keyword(.inout)
296+
#endif
297+
}
298+
}

0 commit comments

Comments
 (0)