SE-0316 (second review): Global Actors

It seems pretty unlike to me that anyone will use anything other than static let here in the first place, so when we're talking about adding a special ad-hoc type-checking rule for a rare case that might be useful. Heck, you need it today if you want a generic global actor, because static variables aren't supported in generic types:

protocol DefaultInitializable {
  init()
}

@globalActor
struct GA<ActorType: Actor & DefaultInitializable> {
  static let shared = ActorType() // error: static stored properties not supported in generic types
}

Doug

Thanks everybody for your help in the review. The core team has decided to accept this proposal with modifications.

2 Likes

I'm late to the review, seeing as it's already been accepted (congratulations!). I wonder if @Douglas_Gregor or another author could give a clarification that seems unanswered in the proposal text--

The proposal gives the following example:

What happens if I define two global actor-annotated protocols, P and Q (distinct global actors), and then write struct X: P, Q? Which is the implicit global actor then, and is there a warning?

In the same vein, but perhaps more likely to occur in real-world code, the proposal states:

What if I define a struct with two members, one annotated with @UIUpdating and another annotated with a custom property wrapper called @BackgroundActorUpdating with a different global actor-qualified wrapped value? What is the inferred global actor for my struct, and is there a warning?