Swift 6's Puzzling `@isolated(any)`: What You Need to Know
2025-09-01

Swift 6 introduces the `@isolated(any)` attribute, which describes the isolation of asynchronous functions, initially appearing confusing. It always requires an argument, but this argument cannot vary. The article explains its introduction: to solve the problem of lost isolation information during asynchronous function scheduling. `@isolated(any)` provides access to a function's isolation property, enabling more intelligent scheduling, especially when handling `Task` and `TaskGroup`, ensuring the execution order of tasks on the MainActor. While it can mostly be ignored, understanding `@isolated(any)` is crucial for writing efficient and reliable concurrent code when dealing with asynchronous function isolation and scheduling.
Development
Asynchronous Functions