Even if you assign the `@MainActor` attribute to a closure, the processing inside the closure is not executed on the main thread

Right. Actor isolation has to be represented in the type of a sync function, or else it just can’t be automatically honored — it’s sync, so only the caller can make sure it runs with the right isolation. In non-strict mode, Swift has to assume that you’re getting it right dynamically somehow, but strict mode makes the compiler diagnose it immediately. SE-0423, if accepted, will at least make Swift diagnose the failure dynamically.

8 Likes