Is it fair to declare Combine's AnyPublisher as unchecked sendable as long as output & error types are sendable?

In case it wasn't clear from the above, you don't even need to send a Publisher to get into trouble:

// thread/task/actor A
// publish some A-isolated state
let subject = PassthroughSubject<NonSendable, Never>()
let publisher: AnyPublisher<Int, Never> = subject
    .receive(on: DispatchQueue.global())
    .sink {
        // access A-isolated state on the global queue
        $0.value
    }
    .store(in: &cancellables)

Here the publisher doesn't leave A, but the sink is run elsewhere.

1 Like