Open knutanderss opened 2 months ago
@knutanderss I'm having a little bit of trouble visualizing the scenario you are talking about. Is it something like this?
func voidFunc() -> Void {
return try await withCheckedThrowingContinuation { ... }
}
If not, perhaps you could provide a code example?
@nicklockwood Some thing like this:
func abc() async throws {
return try await withCheckedThrowingContinuation { continuation in
DispatchQueue.main.async {
someFunctionCall() { result, error in
if let error {
continuation.resume(throwing: error)
} else if let result {
continuation.resume()
}
}
}
}
}
If you remove the return you will get: Generic parameter 'T' could not be inferred
Hi, we had an instance in our codebase where SwiftFormat removed
return
as redundant in front oftry await withCheckedThrowingContinuation { ... }
, which caused a type error. The outer function returnsVoid
, andwithCheckedThrowingContinuation
is generic on its return type, so withoutreturn
the compiler is not able to infer that the generic parameter should beVoid
too.It seems perhaps that
return
is not redundant in front oftry await ...
?Anyway, disabling
redundantReturn
for that line works for now.