From 40200c8b0224fa36b5fec7b1c59c2a0eca33c864 Mon Sep 17 00:00:00 2001 From: Florian Friedrich Date: Fri, 7 Oct 2022 14:14:14 +0200 Subject: [PATCH] Improve diagnostics for depracted `Lock`. Motivation: When using a `Lock` instance handed by another library and calling `withLock` or `withLockVoid` on it, the compiler will issue an incorrect fix-it warning that `withLock` (or `withLockVoid`) was renamed to `NIOLock`. Modifications: The warning results from annotating the extension that adds `withLock` and `withLockVoid` with `@available(*, deprecated, renamed: "NIOLock")`. This removes the annotation and moves these two methods into the main declaration of `Lock`. Result: The fix-it warning no longer appears when using `withLock` or `withLockVoid`. --- Sources/NIOConcurrencyHelpers/lock.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Sources/NIOConcurrencyHelpers/lock.swift b/Sources/NIOConcurrencyHelpers/lock.swift index 5c3d32dc3d..bdf50a1689 100644 --- a/Sources/NIOConcurrencyHelpers/lock.swift +++ b/Sources/NIOConcurrencyHelpers/lock.swift @@ -88,10 +88,7 @@ public final class Lock { precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)") #endif } -} -@available(*, deprecated, renamed: "NIOLock") -extension Lock { /// Acquire the lock for the duration of the given block. /// /// This convenience method should be preferred to `lock` and `unlock` in @@ -294,7 +291,7 @@ internal func debugOnly(_ body: () -> Void) { } #if compiler(>=5.5) && canImport(_Concurrency) -@available(*, deprecated, renamed: "NIOLock") +@available(*, deprecated) extension Lock: Sendable { }