Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented Nov 20, 2025

…rmance is suppressed

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

For example:

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!

…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!
```
@xedin xedin force-pushed the tilde-sendable-cond-conformances branch from c0d04c6 to d868e68 Compare November 20, 2025 00:46
@xedin
Copy link
Contributor Author

xedin commented Nov 20, 2025

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Nov 20, 2025

@swift-ci please smoke test Linux platform

@xedin
Copy link
Contributor Author

xedin commented Nov 20, 2025

@swift-ci please test Windows platform

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Nov 21, 2025

@swift-ci please test Windows platform

public let x: Int
}

// CHECK: #if compiler(>=5.3) && $TildeSendable
Copy link
Contributor

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
}

Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants