Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More support for Swift 6. #31

Merged
merged 1 commit into from
Jul 17, 2024
Merged

More support for Swift 6. #31

merged 1 commit into from
Jul 17, 2024

Conversation

mbrandonw
Copy link
Member

No description provided.

@mbrandonw mbrandonw merged commit 1370f01 into main Jul 17, 2024
7 checks passed
@mbrandonw mbrandonw deleted the swift-6 branch July 17, 2024 17:11
@@ -79,7 +79,7 @@ extension AsyncStream {
extension AsyncSequence {
/// Erases this async sequence to an async stream that produces elements till this sequence
/// terminates (or fails).
public func eraseToStream() -> AsyncStream<Element> {
public func eraseToStream() -> AsyncStream<Element> where Self: Sendable {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this, but unfortunately this means that because Combine is stuck in the past, you can't do this anymore:

publisher.values.eraseToStream()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a @preconcurrency import help with that? Or worst case, a @retroactive @unchecked Sendable conformance for the publisher in question?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a @preconcurrency import help with that?

Nope

a @retroactive @unchecked Sendable conformance for the publisher in question?

Yeah but that would silence all other issues related to mis-using Publishers.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance of relaxing this requirement? We'll be stuck on 1.1.0 otherwise to be able to keep supporting Combine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NachoSoto We recently introduced a conditional conformance to UncheckedSendable here: #44

Can you use that?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's perfect thank you!

Ended up doing this (AnyAsyncSequence is our own type to deal with the Failure associatedtype availability):

extension Publisher where Output: Sendable {
  public func eraseToAnyAsyncSequence() -> AnyAsyncSequence<Output> {
    // Combine does not support Swift concurrency, so we rely on `ConcurrencyExtras`
    // allowing this.
    UncheckedSendable(values).eraseToAnyAsyncSequence()
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants