Avatar
Avatar
Iceman
@swift-6.1.2 -swift-version 6 class NonSendable {} @MainActor func onMainActor() async { let sequence = AsyncStream(unfolding: { NonSendable() }) _ = await sequence.first(where: { _ in true }) for await _ in sequence { break } }
exit status 1 with stderr:<stdin>:6:24: error: non-sendable result type 'NonSendable?' cannot be sent from nonisolated context in call to instance method 'first(where:)' 1 | class NonSendable {} | `- note: class 'NonSendable' does not conform to the 'Sendable' protocol 2 | 3 | @MainActor func onMainActor() async { 4 | let sequence = AsyncStream(unfolding: { NonSendable() }) 5 | 6 | _ = await sequence.first(where: { _ in true }) | `- error: non-sendable result type 'NonSendable?' cannot be sent from nonisolated context in call to instance method 'first(where:)' 7 | 8 | for await _ in sequence {