|
5 | 5 |
|
6 | 6 | ## Swift 6.0
|
7 | 7 |
|
| 8 | +* [SE-0427][]: |
| 9 | + You can now suppress `Copyable` on protocols, generic parameters, |
| 10 | + and existentials: |
| 11 | + |
| 12 | + ```swift |
| 13 | + // Protocol does not require conformers to be Copyable. |
| 14 | + protocol Flower: ~Copyable { |
| 15 | + func bloom() |
| 16 | + } |
| 17 | + |
| 18 | + // Noncopyable type |
| 19 | + struct Marigold: Flower, ~Copyable { |
| 20 | + func bloom() { print("Marigold blooming!") } |
| 21 | + } |
| 22 | + |
| 23 | + // Copyable type |
| 24 | + struct Hibiscus: Flower { |
| 25 | + func bloom() { print("Hibiscus blooming!") } |
| 26 | + } |
| 27 | + |
| 28 | + func startSeason(_ flower: borrowing some Flower & ~Copyable) { |
| 29 | + flower.bloom() |
| 30 | + } |
| 31 | + |
| 32 | + startSeason(Marigold()) |
| 33 | + startSeason(Hibiscus()) |
| 34 | + ``` |
| 35 | + |
| 36 | + By writing `~Copyable` on a generic type, you're suppressing a default |
| 37 | + `Copyable` constraint that would otherwise appear on that type. This permits |
| 38 | + noncopyable types, which have no `Copyable` conformance, to conform to such |
| 39 | + protocols and be substituted for those generic types. Full functionality of this |
| 40 | + feature requires the newer Swift 6 runtime. |
| 41 | + |
8 | 42 | * Since its introduction in Swift 5.1 the @TaskLocal property wrapper was used to
|
9 | 43 | create and access task-local value bindings. Property wrappers introduce mutable storage,
|
10 | 44 | which was now properly flagged as potential source of concurrency unsafety.
|
@@ -10252,6 +10286,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
|
10252 | 10286 | [SE-0412]: https://github.com/apple/swift-evolution/blob/main/proposals/0412-strict-concurrency-for-global-variables.md
|
10253 | 10287 | [SE-0413]: https://github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
|
10254 | 10288 | [SE-0422]: https://github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md
|
| 10289 | +[SE-0427]: https://github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md |
10255 | 10290 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
10256 | 10291 | [#42697]: <https://github.com/apple/swift/issues/42697>
|
10257 | 10292 | [#42728]: <https://github.com/apple/swift/issues/42728>
|
|
0 commit comments