I'm getting the exact same error, very similar circumstances:
extension NSItemProvider {
func loadObject<T>(ofClass: T.Type) async throws -> T? where T : _ObjectiveCBridgeable, T._ObjectiveCType : NSItemProviderReading {
return try await withCheckedThrowingContinuation { continuation in
_ = self.loadObject(ofClass: ofClass) { item, error in
switch (item, error) {
case (.some(let item), .none):
continuation.resume(returning: item) /* Task-isolated value of type 'T' passed as a strongly transferred parameter; later accesses could race; this is an error in the Swift 6 language mode */
case (.none, .some(let error)):
continuation.resume(throwing: error)
default:
let error = NSError(...)
continuation.resume(throwing: error)
}
}
}
}
}
Based on the advice below I changed the method signature to:
func loadObject<T>(ofClass: T.Type) async throws -> T? where T : _ObjectiveCBridgeable, T._ObjectiveCType : NSItemProviderReading, T: Sendable
which seems to have fixed it!