SE-0420: Inheritance of actor isolation

Did you build with -enable-experimental-feature OptionalIsolatedParameters? I tried to build this with -enable-experimental-feature OptionalIsolatedParameters -strict-concurrency=complete on main and I do not see any concurrency warnings:

class NotSendable {}

@MainActor
class ActorIsolatedType {
  func foo() async {
    await (1...3).forEachAsync(MainActor.shared) { _ in
      await bar(NotSendable())
    }
  }
  func bar(_: NotSendable) async {}
}


extension Sequence where Element: Sendable {
  func forEachAsync(_: isolated Actor, _ operation: (Element) async -> Void) async {
    for element in self {
      await operation(element)
    }
  }
}
1 Like

Big +1. I’m very happy to see the continued iteration of making concurrency work for all the use cases out there.

Will there be a separate proposal to adopt this for AsyncSequence?

Yes there is; it's under review at SE-0421: Generalize effect polymorphism for AsyncSequence and AsyncIteratorProtocol.

3 Likes

Thank you all for your review comments. This proposal has been accepted by the language steering group.

1 Like