Skip to content

Commit d60f2ce

Browse files
pblazejclaude
andcommitted
refactor: conform Task to Loggable instead of using a stub enum
Replace the private `DiscardingTask: Loggable` stub with a constrained conformance `Task: Loggable where Success == Void, Failure == Never`, and switch the helpers' logging calls to `Self.log(...)`. Side benefit: log lines now correctly report the originating type as `Task<Void, Never>` rather than the leaking-implementation `DiscardingTask`. The conformance is constrained to the same Task variant the helpers operate on, so the addition doesn't pollute the general Task type. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4d39be8 commit d60f2ce

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Sources/LiveKit/Support/Async/Task+Discarding.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
private enum DiscardingTask: Loggable {}
19+
extension Task: Loggable where Success == Void, Failure == Never {}
2020

2121
extension Task where Success == Void, Failure == Never {
2222
/// Spawn an unstructured task whose thrown errors are discarded.
@@ -40,8 +40,8 @@ extension Task where Success == Void, Failure == Never {
4040
do {
4141
_ = try await operation()
4242
} catch {
43-
DiscardingTask.log("Task error: \(error)", .error,
44-
file: file, function: function, line: line)
43+
Self.log("Task error: \(error)", .error,
44+
file: file, function: function, line: line)
4545
}
4646
}
4747
}
@@ -66,8 +66,8 @@ extension Task where Success == Void, Failure == Never {
6666
do {
6767
_ = try await operation()
6868
} catch {
69-
DiscardingTask.log("Task error: \(error)", .error,
70-
file: file, function: function, line: line)
69+
Self.log("Task error: \(error)", .error,
70+
file: file, function: function, line: line)
7171
}
7272
}
7373
}

0 commit comments

Comments
 (0)