We used to have to mark types as @unchecked Sendable
when they couldn't otherwise be proven safe to the compiler via normal means. I believe I read somewhere that we could instead now mark the type as Sendable
and then annotate necessary properties as nonisolated(unsafe)
.
I know this is a bad example but just to illustrate:
final class X {}
struct Foo: Sendable {
nonisolated(unsafe) var _value: X?
}
However, this generates two warnings in Xcode 15.3 with complete concurrency checking enabled.
'nonisolated' is redundant on struct's stored properties; this is an error in Swift 6
Stored property '_value' of 'Sendable'-conforming struct 'Foo' has non-sendable type 'X?'
Did I entirely make this up? Or perhaps I've done something wrong?