Skip to content

Commit a10f9fe

Browse files
authored
Support SwiftSyntax 602 (#389)
* Support SwiftSyntax 602 * wip * wip
1 parent 9ef1643 commit a10f9fe

File tree

7 files changed

+50
-37
lines changed

7 files changed

+50
-37
lines changed

Package.resolved

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

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let package = Package(
2626
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.4"),
2727
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
2828
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.0"),
29-
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"602.0.0"),
29+
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"603.0.0"),
3030
],
3131
targets: [
3232
.target(

[email protected]

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ let package = Package(
3030
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.4"),
3131
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
3232
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.0"),
33-
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"602.0.0"),
33+
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"603.0.0"),
3434
],
3535
targets: [
3636
.target(
3737
name: "DependenciesTestObserver",
3838
dependencies: [
39-
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
39+
.product(name: "IssueReporting", package: "xctest-dynamic-overlay")
4040
]
4141
),
4242
.target(
@@ -108,7 +108,7 @@ let package = Package(
108108
"DependenciesMacrosPlugin",
109109
.product(name: "MacroTesting", package: "swift-macro-testing"),
110110
]
111-
),
111+
)
112112
])
113113
#endif
114114

Sources/Dependencies/Internal/Deprecations.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,14 @@ extension AsyncThrowingStream where Failure == Error {
105105

106106
// MARK: -
107107

108+
@available(*, deprecated)
109+
@_documentation(visibility: private)
108110
extension ActorIsolated {
109111
@available(
110112
*,
111-
deprecated,
112-
message: "Use the non-async version of 'withValue'."
113+
deprecated,
114+
message: "Use the non-async version of 'withValue'."
113115
)
114-
@_documentation(visibility: private)
115116
public func withValue<T: Sendable>(
116117
_ operation: @Sendable (inout Value) async throws -> T
117118
) async rethrows -> T where Value: Sendable {

Sources/DependenciesMacrosPlugin/DependencyClientMacro.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,22 @@ public enum DependencyClientMacro: MemberAttributeMacro, MemberMacro {
7373
return attributes
7474
}
7575

76-
public static func expansion<D: DeclGroupSyntax, C: MacroExpansionContext>(
76+
#if canImport(SwiftSyntax602)
77+
#else
78+
public static func expansion<D: DeclGroupSyntax, C: MacroExpansionContext>(
79+
of node: AttributeSyntax,
80+
providingMembersOf declaration: D,
81+
in context: C
82+
) throws -> [DeclSyntax] {
83+
try expansion(of: node, providingMembersOf: declaration, conformingTo: [], in: context)
84+
}
85+
#endif
86+
87+
public static func expansion(
7788
of node: AttributeSyntax,
78-
providingMembersOf declaration: D,
79-
in context: C
89+
providingMembersOf declaration: some DeclGroupSyntax,
90+
conformingTo _: [TypeSyntax],
91+
in context: some MacroExpansionContext
8092
) throws -> [DeclSyntax] {
8193
guard let declaration = declaration.as(StructDeclSyntax.self)
8294
else {
@@ -116,7 +128,7 @@ public enum DependencyClientMacro: MemberAttributeMacro, MemberMacro {
116128
switch accessors {
117129
case .getter:
118130
continue
119-
case let .accessors(accessors):
131+
case .accessors(let accessors):
120132
if accessors.contains(where: { $0.accessorSpecifier.tokenKind == .keyword(.get) }) {
121133
continue
122134
}
@@ -295,7 +307,7 @@ extension VariableDeclSyntax {
295307
fileprivate func hasMacroAttached(_ macro: String) -> Bool {
296308
self.attributes.contains {
297309
guard
298-
case let .attribute(attribute) = $0,
310+
case .attribute(let attribute) = $0,
299311
let attributeName = attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text,
300312
[macro].qualified("DependenciesMacros").contains(attributeName)
301313
else { return false }

Tests/DependenciesMacrosPluginTests/DependencyEndpointMacroTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
953953
} expansion: {
954954
#"""
955955
struct Client {
956-
var endpoint: () -> Void // This is a comment {
956+
var endpoint: () -> Void { // This is a comment
957957
get {
958958
_endpoint
959959
}

Tests/DependenciesTests/FireAndForgetTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@ final class FireAndForgetTests: XCTestCase {
88
#if !os(WASI)
99
@MainActor
1010
func testTestContext() async throws {
11-
let didExecute = ActorIsolated(false)
11+
let didExecute = LockIsolated(false)
1212

1313
await self.fireAndForget {
1414
try await Task.sleep(nanoseconds: 100_000_000)
15-
await didExecute.setValue(true)
15+
didExecute.setValue(true)
1616
}
1717

18-
let value = await didExecute.value
18+
let value = didExecute.value
1919
XCTAssertEqual(value, true)
2020
}
2121

2222
@MainActor
2323
func testTestContext_Cancellation() async throws {
24-
let didExecute = ActorIsolated(false)
24+
let didExecute = LockIsolated(false)
2525

2626
let task = Task {
2727
await self.fireAndForget {
2828
try await Task.sleep(nanoseconds: 1_000_000_000)
29-
await didExecute.setValue(true)
29+
didExecute.setValue(true)
3030
}
3131
}
3232
try await Task.sleep(nanoseconds: 500_000_000)
3333
task.cancel()
3434
await task.value
3535

36-
let value = await didExecute.value
36+
let value = didExecute.value
3737
XCTAssertEqual(value, true)
3838
}
3939

@@ -42,18 +42,18 @@ final class FireAndForgetTests: XCTestCase {
4242
try await withDependencies {
4343
$0.context = .live
4444
} operation: {
45-
let didExecute = ActorIsolated(false)
45+
let didExecute = LockIsolated(false)
4646

4747
await self.fireAndForget {
4848
try await Task.sleep(nanoseconds: 100_000_000)
49-
await didExecute.setValue(true)
49+
didExecute.setValue(true)
5050
}
5151

52-
var value = await didExecute.value
52+
var value = didExecute.value
5353
XCTAssertEqual(value, false)
5454

5555
try await Task.sleep(nanoseconds: 500_000_000)
56-
value = await didExecute.value
56+
value = didExecute.value
5757
XCTAssertEqual(value, true)
5858
}
5959
}
@@ -66,7 +66,7 @@ final class FireAndForgetTests: XCTestCase {
6666
$0.context = .live
6767
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
6868
} operation: {
69-
let date = ActorIsolated<Date?>(nil)
69+
let date = LockIsolated<Date?>(nil)
7070

7171
await self.fireAndForget(priority: .userInitiated) {
7272
@Dependency(\.date.now) var now: Date

0 commit comments

Comments
 (0)