Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.4"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"602.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"603.0.0"),
],
targets: [
.target(
Expand Down
6 changes: 3 additions & 3 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-clocks", from: "1.0.4"),
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.4.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"602.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"603.0.0"),
],
targets: [
.target(
name: "DependenciesTestObserver",
dependencies: [
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
.product(name: "IssueReporting", package: "xctest-dynamic-overlay")
]
),
.target(
Expand Down Expand Up @@ -108,7 +108,7 @@ let package = Package(
"DependenciesMacrosPlugin",
.product(name: "MacroTesting", package: "swift-macro-testing"),
]
),
)
])
#endif

Expand Down
7 changes: 4 additions & 3 deletions Sources/Dependencies/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ extension AsyncThrowingStream where Failure == Error {

// MARK: -

@available(*, deprecated)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few unrelated changes to get rid of some deprecation warnings in the project/tests.

@_documentation(visibility: private)
extension ActorIsolated {
@available(
*,
deprecated,
message: "Use the non-async version of 'withValue'."
deprecated,
message: "Use the non-async version of 'withValue'."
)
@_documentation(visibility: private)
public func withValue<T: Sendable>(
_ operation: @Sendable (inout Value) async throws -> T
) async rethrows -> T where Value: Sendable {
Expand Down
22 changes: 17 additions & 5 deletions Sources/DependenciesMacrosPlugin/DependencyClientMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,22 @@ public enum DependencyClientMacro: MemberAttributeMacro, MemberMacro {
return attributes
}

public static func expansion<D: DeclGroupSyntax, C: MacroExpansionContext>(
#if canImport(SwiftSyntax602)
#else
public static func expansion<D: DeclGroupSyntax, C: MacroExpansionContext>(
of node: AttributeSyntax,
providingMembersOf declaration: D,
in context: C
) throws -> [DeclSyntax] {
try expansion(of: node, providingMembersOf: declaration, conformingTo: [], in: context)
}
#endif

public static func expansion(
of node: AttributeSyntax,
providingMembersOf declaration: D,
in context: C
providingMembersOf declaration: some DeclGroupSyntax,
conformingTo _: [TypeSyntax],
in context: some MacroExpansionContext
) throws -> [DeclSyntax] {
guard let declaration = declaration.as(StructDeclSyntax.self)
else {
Expand Down Expand Up @@ -116,7 +128,7 @@ public enum DependencyClientMacro: MemberAttributeMacro, MemberMacro {
switch accessors {
case .getter:
continue
case let .accessors(accessors):
case .accessors(let accessors):
if accessors.contains(where: { $0.accessorSpecifier.tokenKind == .keyword(.get) }) {
continue
}
Expand Down Expand Up @@ -295,7 +307,7 @@ extension VariableDeclSyntax {
fileprivate func hasMacroAttached(_ macro: String) -> Bool {
self.attributes.contains {
guard
case let .attribute(attribute) = $0,
case .attribute(let attribute) = $0,
let attributeName = attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text,
[macro].qualified("DependenciesMacros").contains(attributeName)
else { return false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ final class DependencyEndpointMacroTests: BaseTestCase {
} expansion: {
#"""
struct Client {
var endpoint: () -> Void // This is a comment {
var endpoint: () -> Void { // This is a comment
get {
_endpoint
}
Expand Down
22 changes: 11 additions & 11 deletions Tests/DependenciesTests/FireAndForgetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ final class FireAndForgetTests: XCTestCase {
#if !os(WASI)
@MainActor
func testTestContext() async throws {
let didExecute = ActorIsolated(false)
let didExecute = LockIsolated(false)

await self.fireAndForget {
try await Task.sleep(nanoseconds: 100_000_000)
await didExecute.setValue(true)
didExecute.setValue(true)
}

let value = await didExecute.value
let value = didExecute.value
XCTAssertEqual(value, true)
}

@MainActor
func testTestContext_Cancellation() async throws {
let didExecute = ActorIsolated(false)
let didExecute = LockIsolated(false)

let task = Task {
await self.fireAndForget {
try await Task.sleep(nanoseconds: 1_000_000_000)
await didExecute.setValue(true)
didExecute.setValue(true)
}
}
try await Task.sleep(nanoseconds: 500_000_000)
task.cancel()
await task.value

let value = await didExecute.value
let value = didExecute.value
XCTAssertEqual(value, true)
}

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

await self.fireAndForget {
try await Task.sleep(nanoseconds: 100_000_000)
await didExecute.setValue(true)
didExecute.setValue(true)
}

var value = await didExecute.value
var value = didExecute.value
XCTAssertEqual(value, false)

try await Task.sleep(nanoseconds: 500_000_000)
value = await didExecute.value
value = didExecute.value
XCTAssertEqual(value, true)
}
}
Expand All @@ -66,7 +66,7 @@ final class FireAndForgetTests: XCTestCase {
$0.context = .live
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
} operation: {
let date = ActorIsolated<Date?>(nil)
let date = LockIsolated<Date?>(nil)

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