Skip to content

Commit 68c3c4a

Browse files
committed
Remove ~Sendable and @~Sendable
1 parent 7eeaf77 commit 68c3c4a

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

proposals/NNNN-global-actor-isolated-types-usability.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ We propose that:
103103
- Stored properties of `Sendable` type in a global-actor-isolated value type are treated as `nonisolated` when used within the module or if the value type is `frozen`.
104104
- `@Sendable` is inferred for global-actor-isolated functions and closures.
105105
- Global-actor-isolated closures are allowed to capture non-`Sendable` values despite being `@Sendable`.
106-
- The programmer would be able to suppress the automatic conformance inferred via the above rule using the new `@~Sendable` attribute. By analogy, introduce a new `~Sendable` protocol to indicate that a nominal type is not `Sendable`.
107106
- A global-actor-isolated subclass of a non-isolated, non-`Sendable` class is allowed, but it must be non-`Sendable`.
108107

109108

@@ -174,45 +173,6 @@ The above code is data-race safe, since a globally isolated closure will never o
174173
Note that under region isolation in SE-0414, capturing a non-`Sendable` value in an actor-isolated closure will transfer the region into the actor, so it is impossible to have concurrent access on non-`Sendable` captures even if the isolated closure is formed outside the actor.
175174

176175

177-
### `@~Sendable` and `~Sendable`
178-
179-
This proposal also adds a way to "opt-out" of the implicit `@Sendable` inference introduced by the above change by using the new `@~Sendable` attribute:
180-
181-
```swift
182-
func test() {
183-
let closure: @~Sendable @MainActor () -> Void = {
184-
print("hmmmm")
185-
}
186-
187-
Task {
188-
await closure() // error
189-
}
190-
}
191-
```
192-
193-
In the above code, we use `@~Sendable` to explicitly indicate that the closure is not `Sendable` and suppress the implicit `@Sendable`. This change will mostly help with possible ABI compatibility issues, but will not necessarily improve usability.
194-
195-
By analogy, this proposal inroduces the new `~Sendable` syntax for explicitly suppressing a conformance to `Sendable`:
196-
197-
```swift
198-
class C { ... }
199-
200-
@available(*, unavailable)
201-
extension C: @unchecked Sendable {}
202-
203-
// instead
204-
205-
class C: ~Sendable {}
206-
```
207-
208-
In the above code, we use `~Sendable` instead of an unavailable `Sendable` conformance to indicate that the type `C` is not `Sendable`. Suppressing a `Sendable` conformance in a superclass still allows a conformance to be added in subclasses:
209-
210-
```swift
211-
class Sub: C, @unchecked Sendable { ... }
212-
```
213-
214-
Previously, an unavailable `Sendable` conformance would prevent `@unchecked Sendable` conformances from being added to subclasses because types can only conform to protocols in one way, and the unavailable `Sendable` conformance was inherited in all subclasses.
215-
216176
### Global actor isolation and inheritance
217177

218178
Subclasses may add global actor isolation when inheriting from a nonisolated, non-`Sendable` superclass. In this case, an implicit conformance to `Sendable` will not be added, and explicitly specifying a `Sendable` conformance is an error:

0 commit comments

Comments
 (0)