Skip to content

Commit 1983448

Browse files
sidepelicanktoso
andauthored
Fix deprecated message cannot handle in swift 5 (#51)
Co-authored-by: Konrad `ktoso` Malawski <[email protected]>
1 parent 42ef73f commit 1983448

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Sources/ServiceContextModule/ServiceContext.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,12 @@ extension ServiceContext {
260260
}
261261

262262
@available(*, deprecated, message: "Use the method with the isolation parameter instead.")
263+
// Deprecated trick to avoid executor hop here; 6.0 introduces the proper replacement: #isolation
263264
@_disfavoredOverload
264265
public static func withValue<T>(_ value: ServiceContext?, operation: () async throws -> T) async rethrows -> T {
265266
try await ServiceContext.$current.withValue(value, operation: operation)
266267
}
267268
#else
268-
// Deprecated trick to avoid executor hop here; 6.0 introduces the proper replacement: #isolation
269-
@available(*, deprecated, message: "Prefer withValue(_:isolation:operation:)")
270-
@_disfavoredOverload
271269
@_unsafeInheritExecutor
272270
public static func withValue<T>(_ value: ServiceContext?, operation: () async throws -> T) async rethrows -> T {
273271
try await ServiceContext.$current.withValue(value, operation: operation)

Tests/ServiceContextTests/ServiceContextTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ final class ServiceContextTests: XCTestCase {
9494
ServiceContext.withValue(.topLevel) {
9595
value = 12 // should produce no warnings
9696
}
97+
await ServiceContext.withValue(.topLevel) { () async in
98+
value = 12 // should produce no warnings
99+
}
97100
}
98101
}
99102

0 commit comments

Comments
 (0)