Skip to content

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

Closed
@jm-alan

Description

@jm-alan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions