Avatar
@swift-main import SwiftUI class NonSendable { var bool: Bool = .random() } func makeNonSendable() async -> NonSendable { NonSendable() } @MainActor struct Demo { private var bool: Bool? { nonmutating set {} get { nil } } nonisolated func foo() async { let ns = await makeNonSendable() Task { @MainActor in bool = ns.bool } } var body: some View { Text("Hello, World!") // .task { // NG // let ns = await makeNonSendable() // bool = ns.bool // } .task { // OK await foo() } } }