Skip to content

Swift 6 warning: No async operations occur #227

Answered by stephencelis
seanmrich asked this question in Q&A
Discussion options

You must be logged in to vote

@seanmrich This looks like a Swift bug. I can reproduce outside of swift-dependencies and mainly seems to be the static let assignment:

let f: @Sendable () async -> Int = {
  actor A { var p = 0 }
  return await A().p
}

Want to file a bug with Apple and ask what the expected behavior is?

In your case you can change to a computed static var to fix. But I'd also suggest not using ActorIsolated. We think that LockIsolated should almost always be preferred, and are having enough of a hard time motivating ActorIsolated that we will probably deprecate it soon.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@seanmrich
Comment options

Answer selected by seanmrich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants