Distinction between `@isolated(any)` and `@_inheritActorContext`

I think this is related to how @_inheritActorContext interacts with isolated parameters. You might be interested in:

But for now, you can try explicitly capturing the isolated param value within the Task body like this:

return Task { [weak object] in
        _ = isolation // a capture affects the static isolation
        for try await element in stream {
            guard !Task.isCancelled,
                  let object
            else { return }

            try operation(object, element)
        }
    }
1 Like