[Concurrency] Allow conditionally conforming to Sendable when conformance is suppressed

For consistency with invertible protocols using `~Sendable` should
only prohibit use of unconditional extensions.

For example:

```swift
struct G<T>: ~Sendable {}
```

The following (unconditional) extension is rejected:

```
extension G: Sendable {} // error: cannot both conform to and suppress conformance to 'Sendable'
```

But conditional on `T` is accepted:

```
extension G: Sendable where T: Sendable {} // Ok!
```
This commit is contained in:
Pavel Yaskevich
2025-11-19 16:37:17 -08:00
parent 5cc8264d8d
commit d868e68cd2
3 changed files with 73 additions and 8 deletions

View File

@@ -33,3 +33,18 @@ protocol P {
public struct S: P, ~Sendable {
public let x: Int
}
// CHECK: #if compiler(>=5.3) && $TildeSendable
// CHECK: public struct B<T> : ~Swift.Sendable {
// CHECK: }
// CHECK: #else
// CHECK: public struct B<T> {
// CHECK: }
// CHECK: #endif
public struct B<T>: ~Sendable {
}
// CHECK: extension Library.B : Swift.Sendable where T : Swift.Sendable {
// CHECK: }
extension B: Sendable where T: Sendable {
}