Skip to content

[SR-15936] @preconcurrency doesn't work with associatedtype Sendable requirement #58197

@adam-fowler

Description

@adam-fowler
Previous ID SR-15936
Radar rdar://problem/90348980
Original Reporter @adam-fowler
Type Bug
Environment

Apple Swift version 5.6-dev (LLVM 62b900d3d0d5be9, Swift ce64fe8)
Download from website swift-5.6-DEVELOPMENT-SNAPSHOT-2022-02-11-a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: e5a048a35d490a3357492b603ff2f812

Issue Description:

I'm not sure if this is a bug or not. The following code does not compile

@preconcurrency import Foundation

protocol TestProtocol {
    associatedtype Value: Sendable
}

struct Test: TestProtocol {
    typealias Value = Date
    let value: Value
}

The compiler errors with "type 'Test' does not conform to protocol 'TestProtocol'". This appears to be because Date doesn't conform to Sendable. I thought prefixing the Foundation import with @preconcurrency was meant to get around this.

I can fix the code by removing the @preconcurrency and adding

extension Date: @unchecked Sendable {}

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions