A deep dive into how Swift protocols interact with global actors like @MainActor, exploring the trade-offs between whole-protocol isolation and per-requirement isolation. Covers a surprising compiler limitation that prevents actors from conforming to global-actor-isolated protocols — and reveals it's an artificial restriction being fixed. Also examines how protocol isolation behaves differently when conformance is declared at the type level versus in an extension, and argues that nonisolated protocols with Swift 6.2's isolated conformances feature are often the better design choice.

8m read timeFrom massicotte.org
Post cover image
Table of contents
An Even Closer Look at Protocols and Global ActorsWhat should be MainActor?"Whole-Protocol Isolation"The GapOk, so... now what?Maybe nonisolated?Thinking in constraints
366 Impressions