sourcekit-lsp
sourcekit-lsp copied to clipboard
`NSLock` triggers a warning when a containing struct is `Sendable` even though `NSLock` conforms to `Sendable`
When creating a struct with an internal NSLock, e.g.
struct MyLockWrapper {
let lock: NSLock = .init()
}
and confirming this struct to Sendable
extension MyLockWrapper: Sendable {}
SourceKitD generates the following warning about NSLock not conforming to Sendable:
stored property 'lock' of 'Sendable'-conforming struct 'MyLockWrapper' has non-sendable type 'NSLock'
Even though the Apple developer documentation explicitly says it does
Tracked in Apple’s issue tracker as rdar://119250614
Do you also see this warning during compilation? And: Which version of swift/sourcekit-lsp are you using?
This could also be platform-dependent, Apple documentation doesn't cover swift-corelibs-libdispatch, which largely lacks Sendable annotations for vast majority of its types.
Looks like Sendable conformance to NSLock was added recently to swift-corelibs-foundation, which is used on Linux: https://github.com/apple/swift-corelibs-foundation/pull/4944