[Prospective Vision] Improving the approachability of data-race safety

Thank you for putting this together. I'm excited about a number of ideas being proposed.

Nonetheless, we are tentatively very excited about the potential for this feature to fix problems with how Swift's generics system interacts with isolated types, especially global-actor-isolated types.

In [Review] SF-0011: Concurrency-Safe Notifications, we propose a protocol Message and another called MainActorMessage, the latter existing so that function overloads decorated with @MainActor are used for Message types that are effectively main actor-bound. It would be nice to not have MainActorMessage and instead have the generics system select an overload based on global actor conformance, e.g.:

// General overload
genericFunc<M: Message>(…)

// MainActor-overload
@MainActor genericFunc<M: Message & @MainActor>(…) // some kind of syntax expressing that the generic type has an isolation conformance requirement
2 Likes