Skip to content

incorrect warning "Instance method of non-Sendable type 'Self.Type' cannot be marked as '@Sendable'" #85692

@lukaskollmer

Description

@lukaskollmer

Description

marking a static function in a protocol as @Sendable causes the compiler to emit a warning "Instance method of non-Sendable type 'Self.Type' cannot be marked as '@sendable'", which doesn't seem to be correct since a) the method in question is a static method rather than an instance method, and b) it's irrelevant if the type is Sendable (bc it's a static method...)

Reproduction

protocol P {
    @Sendable static func f()
    // ^ Instance method of non-Sendable type 'Self.Type' cannot be marked as '@Sendable'
}

Expected behavior

this should work without warnings

Environment

swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx15.0

Additional information

i'm able to reproduce this when compiling an SPM package using swift build and when compiling via Xcode, but it seems that using either swiftc or swift to compile just a single file containing just this protocol definition compiles without emitting the warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions