Why no compiler error for this Swift Concurrency/Combine code?

Hi @mjholgate, this is discussed in this part of the Swift 6 migration guide. It is a sharp edge when migrating, but it's just how things are right now. Because MyClass is isolated to @MyActor, the sink trailing closure is automatically inferred to be @MyActor too, even though it is not. If you mark the trailing closure as @Sendable, then you will get a compiler error forcing you to provide isolation to access self.

This doesn't have anything to do with Combine, and affects all pre-concurrency code out there.

3 Likes