You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,36 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
5
5
6
6
## Swift 5.7
7
7
8
+
*[SE-0336][]:
9
+
10
+
It is now possible to declare `distributed actor` and `distributed func`s inside of them.
11
+
12
+
Distributed actors provide stronger isolation guarantees than "local" actors, and enable additional checks to be made on return types and parameters of distributed methods, e.g. checking if they conform to `Codable`. Distributed methods can be called on "remote" references of distributed actors, turning those invocations into remote procedure calls, by means of pluggable and user extensible distributed actor system implementations.
13
+
14
+
Swift does not provide any specific distributed actor system by itself, however, packages in the ecosystem fulfil the role of providing those implementations.
15
+
16
+
```swift
17
+
distributedactorGreeter {
18
+
var greetingsSent =0
19
+
20
+
distributedfuncgreet(name: String) ->String {
21
+
greetingsSent +=1
22
+
return"Hello, \(name)!"
23
+
}
24
+
}
25
+
26
+
functalkTo(greeter: Greeter) asyncthrows {
27
+
// isolation of distributed actors is stronger, it is impossible to refer to
28
+
// any stored properties of distributed actors from outside of them:
29
+
greeter.greetingsSent// distributed actor-isolated property 'name' can not be accessed from a non-isolated context
30
+
31
+
// remote calls are implicitly throwing and async,
32
+
// to account for the potential networking involved:
33
+
let greeting =tryawait greeter.greet(name: "Alice")
34
+
print(greeting) // Hello, Alice!
35
+
}
36
+
```
37
+
8
38
* The compiler now emits a warning when a non-final class conforms to a protocol that imposes a same-type requirement between `Self` and an associated type. This is because such a requirement makes the conformance unsound for subclasses.
9
39
10
40
For example, Swift 5.6 would allow the following code, which at runtime would construct an instanec of `C` and not `SubC` as expected:
0 commit comments