Should global-actor-isolated functions be implicitly Sendable?

I now have run into something that I think is similar/same, and I'm really struggling to understand.

@MainActor
class MyClass {
	func doThing() {
	}
}

func test() {
	let closure: @MainActor () -> Void = {
		print("hmmmm")
	}

	let value = MyClass()

	Task {
		// warning about capturing non-Sendable
		await closure()

		// this is fine
		await value.doThing()
	}
}

Under what conditions would this actually be unsafe?

1 Like