How the Swift compiler knows that DispatchQueue.main implies @MainActor
['Ole Begemann']
Ole Begemann
async { // Error: Call to main actor-isolated global function // 'mainActorFunc()' in a synchronous nonisolated context mainActorFunc () // ❌ } typealias DP = DispatchQueue DP . async { // Error: Call to main actor-isolated global function // 'mainActorFunc()' in a synchronous nonisolated context mainActorFunc () // ❌ } Fun fact: since this is a purely syntax-based check, if you define your own type named DispatchQueue , give it a static main property and a function named async that takes a closure, the compiler will apply the same “fix” to it.