It’s my understanding that unstructured concurrency means actor inheritance is not guaranteed.
SE-0304 (Structured Concurrency)
This proposal only explicitly defines structured concurrency (async let, TaskGroup).
It does not explicitly say that Task {} does not inherit actor isolation.
It does say structured tasks inherit actor context, implying Task {} (which is unstructured) is different.
SE-0306 (Sendable and Actor Isolation)
This proposal explicitly states:
@Sendable closures are always non-isolated.
Since Task {} is not @Sendable by default, this leaves open the possibility that it may inherit actor isolation.
Apple Swift Concurrency Guide
The best direct quote about Task {} comes from Apple documentation:
Tasks automatically inherit the priority and task-local storage of the context they are created in. However, actor isolation depends on how the task is scheduled.
(Apple Swift Concurrency Docs)
This confirms actor inheritance is not guaranteed for Task {}.
Since there is no single place where Swift explicitly says Task does not inherit actor isolation, the conclusion is inferred from:
SE-0304 making a distinction between structured and unstructured tasks.
SE-0306 stating @Sendable closures do not inherit isolation.
Apple documentation saying actor inheritance in Task {} depends on scheduling.
Practical testing of Task {} in different contexts, which shows it does not always inherit actor isolation.
What We Know for Sure
-
Structured tasks (async let, TaskGroup) always inherit actor isolation.
-
Unstructured Task {} does not automatically inherit actor isolation, but it may.
-
Task.detached {} never inherits actor isolation.
-
If a closure inside Task {} is explicitly @Sendable, it will never inherit actor isolation.
What Is Not Explicitly Stated
There is no single document that explicitly states: Task {}` does not inherit actor isolation.
Instead, Apple’s documentation says it depends on scheduling, which implies it’s not guaranteed.
Instead of saying Task {} does not inherit actor isolation, the most precise way to state it is:
Task {} is unstructured concurrency, so it does not guarantee actor inheritance. It may inherit the surrounding actor context, but this depends on scheduling, and it is not something developers should rely on.
This aligns with:
SE-0304 (which differentiates structured/unstructured tasks).
SE-0306 (which confirms @Sendable closures are never actor-isolated).
Apple’s documentation (which explicitly states actor inheritance in Task {} depends on scheduling).
Would you agree this is a more precise way to phrase it?