-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Concurrency] Allow conditionally conforming to Sendable when confo…
#85605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rmance 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!
```
c0d04c6 to
d868e68
Compare
|
@swift-ci please smoke test |
|
@swift-ci please smoke test Linux platform |
|
@swift-ci please test Windows platform |
1 similar comment
|
@swift-ci please test Windows platform |
| public let x: Int | ||
| } | ||
|
|
||
| // CHECK: #if compiler(>=5.3) && $TildeSendable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity – is this meant to be a check for 5.3 or 6.3? if it is 5.3, why is that version relevant?
| check(NonSendable()) // expected-warning {{type 'NonSendable' does not conform to the 'Sendable' protocol}} | ||
| check(NoInference()) // Ok | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a test for how this conditional conformance behavior works with classes and inheritance? and perhaps for completion, some enum tests should be included too?
also, when messing with whatever version is on the nightly godbolt, it also seems like this is accepted on the current snapshot (57cf4ce), which seems wrong, or at least confusing:
actor A: ~Sendable {}presumably that is due to its being a ClassDecl or something.
edit: oh, and another case occurs to me – should we have a case to test a conditional Sendable conformance to another protocol that refines Sendable?
…rmance is suppressed
For consistency with invertible protocols using
~Sendableshould only prohibit use of unconditional extensions.For example:
The following (unconditional) extension is rejected:
But conditional on
Tis accepted: