Skip to content

@preconcurrency conformances warns for inherited protocols #82782

Open
@Lancelotbronner

Description

@Lancelotbronner

Description

The following code snippet has two unnecessary warnings with misleading fix-its.

  • @preconcurrency attribute on conformance to 'URLSessionDelegate' has no effect
  • @preconcurrency attribute on conformance to 'Sendable' has no effect

While they're right, neither of those are in the conformance list. Only URLSessionDataDelegate is, where @preconcurrency does have an effect.

The fix-its recommend removing the @preconcurrency attribute which removes it from URLSessionDataDelegate, breaking everything.

The proper fix would be to add a URLSessionDelegate conformance without the @preconcurrency attribute so they can inherit their isolation.
Since Sendable is specified by URLSessionDelegate, that'll fix both but the fix would also have applied to it.

Reproduction

@MainActor final class Example: NSObject, @preconcurrency URLSessionDataDelegate {
    func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {}
}

Expected behavior

The fix-it suggestions should be fixed.

Environment

$ xcrun swiftc --version
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0

Additional information

No response

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