mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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 {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user