closures can currently be isolated in two ways:
- via a gobal-actor-isolated type annotation
- via a capture of an isolated parameter
for the second case, i was a bit surprised to find that certain forms of isolated parameter capture don't appear to 'count' for the purposes of this isolation determination. e.g. this works
func test_captures(isolation: isolated any Actor) async {
await withTaskCancellationHandler {
isolation.assertIsolated() // ✅ - isolation captured from outer scope
} onCancel: {}
}
but this surprisingly does not:
func test_captures(isolation: isolated any Actor) async {
await withTaskCancellationHandler { [isolation] in
isolation.assertIsolated() // 🛑 - isolation aliased via capture list entry
} onCancel: {}
}
is this behavior expected?