Skip to content

Commit 382cd4c

Browse files
committed
[CHANGELOG] NFC: Add an entry for SE-0418
1 parent 319f36b commit 382cd4c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,44 @@
55
66
## Swift 6.0
77

8+
* [SE-0418][]:
9+
10+
The compiler would now automatically employ `Sendable` on functions
11+
and key path literal expressions that cannot capture non-Sendable values.
12+
13+
This includes partially-applied and unapplied instance methods of `Sendable`
14+
types, as well as non-local functions. Additionally, it is now disallowed
15+
to utilize `@Sendable` on instance methods of non-Sendable types.
16+
17+
Let's use the following type to illustrate the new inference rules:
18+
19+
```swift
20+
public struct User {
21+
var name: String
22+
23+
func getAge() -> Int { ... }
24+
}
25+
```
26+
27+
Key path `\User.name` would be inferred as `WritableKeyPath<User, String> & Sendable`
28+
because it doesn't capture any non-Sendable values.
29+
30+
The same applies to keypath-as-function conversions:
31+
32+
```swift
33+
let _: @Sendable (User) -> String = \User.name // Ok
34+
```
35+
36+
A function value produced by an un-applied reference to `getAge`
37+
would be marked as `@Sendable` because `User` is a `Sendable` struct:
38+
39+
```swift
40+
let _ = User.getAge // Inferred as `@Sendable (User) -> @Sendable () -> Int`
41+
42+
let user = User(...)
43+
user.getAge // Inferred as `@Sendable () -> Int`
44+
```
45+
846
* [SE-0432][]:
947
Noncopyable enums can be pattern-matched with switches without consuming the
1048
value you switch over:
@@ -10327,6 +10365,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1032710365
[SE-0427]: https://github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
1032810366
[SE-0429]: https://github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
1032910367
[SE-0432]: https://github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
10368+
[SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
1033010369
[#64927]: <https://github.com/apple/swift/issues/64927>
1033110370
[#42697]: <https://github.com/apple/swift/issues/42697>
1033210371
[#42728]: <https://github.com/apple/swift/issues/42728>

0 commit comments

Comments
 (0)