Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSLock triggers a warning when a containing struct is Sendable even though NSLock conforms to Sendable #986

Open
jm-alan opened this issue Dec 6, 2023 · 3 comments

Comments

@jm-alan
Copy link

jm-alan commented Dec 6, 2023

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

@ahoppen
Copy link
Collaborator

ahoppen commented Dec 6, 2023

Tracked in Apple’s issue tracker as rdar://119250614

@ahoppen
Copy link
Collaborator

ahoppen commented Dec 6, 2023

Do you also see this warning during compilation? And: Which version of swift/sourcekit-lsp are you using?

@MaxDesiatov
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants