Skip to content

Complete strict concurrency checking enabled - Sendable classes with @Dependency #204

Answered by mbrandonw
niorko asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @niorko, this is just the reality of property wrappers and concurrency. Every property wrapper is going to have this problem because they secretly create a var _ property, which of course does not play nicely with sendability. There was a proposal to allow for property wrappers with let, but it never went anywhere.

However, typically is very hard to make a class Sendable. Does your class truly have no mutable state whatsoever? If it does, then usually you have to provide your own locking under the hood and use @unchecked Sendable. And in that case then the warning goes away and you should make never mutate through _testClient.

Or alternatively you need to synchronize the entire class u…

Replies: 2 comments 3 replies

Comment options

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

Answer selected by niorko
Comment options

You must be logged in to vote
2 replies
@qasim
Comment options

@mbrandonw
Comment options

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