diff --git a/Sources/ServiceContextModule/ServiceContext.swift b/Sources/ServiceContextModule/ServiceContext.swift index 8500b60..e7b44fb 100644 --- a/Sources/ServiceContextModule/ServiceContext.swift +++ b/Sources/ServiceContextModule/ServiceContext.swift @@ -257,14 +257,12 @@ extension ServiceContext { } @available(*, deprecated, message: "Use the method with the isolation parameter instead.") + // Deprecated trick to avoid executor hop here; 6.0 introduces the proper replacement: #isolation @_disfavoredOverload public static func withValue(_ value: ServiceContext?, operation: () async throws -> T) async rethrows -> T { try await ServiceContext.$current.withValue(value, operation: operation) } #else - // Deprecated trick to avoid executor hop here; 6.0 introduces the proper replacement: #isolation - @available(*, deprecated, message: "Prefer withValue(_:isolation:operation:)") - @_disfavoredOverload @_unsafeInheritExecutor public static func withValue(_ value: ServiceContext?, operation: () async throws -> T) async rethrows -> T { try await ServiceContext.$current.withValue(value, operation: operation) diff --git a/Tests/ServiceContextTests/ServiceContextTests.swift b/Tests/ServiceContextTests/ServiceContextTests.swift index 496c23c..476be07 100644 --- a/Tests/ServiceContextTests/ServiceContextTests.swift +++ b/Tests/ServiceContextTests/ServiceContextTests.swift @@ -94,6 +94,9 @@ final class ServiceContextTests: XCTestCase { ServiceContext.withValue(.topLevel) { value = 12 // should produce no warnings } + await ServiceContext.withValue(.topLevel) { () async in + value = 12 // should produce no warnings + } } }