@@ -20,6 +20,33 @@ CHANGELOG
2020Swift 3.1
2121---------
2222
23+ * The ` withoutActuallyEscaping ` function from [ SE-0103] [ ] has been implemented.
24+ To pass off a non-escaping closure to an API that formally takes an
25+ ` @escaping ` closure, but which is used in a way that will not in fact
26+ escape it in practice, use ` withoutActuallyEscaping ` to get an escapable
27+ copy of the closure and delimit its expected lifetime. For example:
28+
29+ ``` swift
30+ func doSimultaneously (_ f : () -> (), and g : () -> (), on q : DispatchQueue) {
31+ // DispatchQueue.async normally has to be able to escape its closure
32+ // since it may be called at any point after the operation is queued.
33+ // By using a barrier, we ensure it does not in practice escape.
34+ withoutActuallyEscaping (f) { escapableF in
35+ withoutActuallyEscaping (g) { escapableG in
36+ q.async (escapableF)
37+ q.async (escapableG)
38+ q.sync (flags : .barrier ) {}
39+ }
40+ }
41+ // `escapableF` and `escapableG` must be dequeued by the point
42+ // `withoutActuallyEscaping` returns.
43+ }
44+ ```
45+
46+ The old workaround of using ` unsafeBitCast ` to cast to an ` @escaping ` type
47+ is not guaranteed to work in future versions of Swift, and will
48+ now raise a warning.
49+
2350* [ SR-1446] ( https://bugs.swift.org/browse/SR-1446 )
2451
2552 Nested types may now appear inside generic types, and nested types may have their own generic parameters:
@@ -300,8 +327,8 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
300327 ```swift
301328 let a: Foo & Bar
302329 let b = value as? A & B & C
303- func foo< T : Foo & Bar> (x : T) { … }
304- func bar (x : Foo & Bar) { … }
330+ func foo< T : Foo & Bar> (x : T) { ... }
331+ func bar (x : Foo & Bar) { ... }
305332 typealias G = GenericStruct< Foo & Bar>
306333 ```
307334
@@ -1079,7 +1106,7 @@ Swift 2.0
10791106* Public extensions of generic types are now permitted.
10801107
10811108 ```swift
1082- public extension Array { … }
1109+ public extension Array { ... }
10831110 ```
10841111
10851112 ** (16974298 )**
@@ -1239,8 +1266,8 @@ Swift 2.0
12391266 For example:
12401267
12411268 ```swift
1242- func produceGizmoUsingTechnology () throws -> Gizmo { … }
1243- func produceGizmoUsingMagic () throws -> Gizmo { … }
1269+ func produceGizmoUsingTechnology () throws -> Gizmo { ... }
1270+ func produceGizmoUsingMagic () throws -> Gizmo { ... }
12441271
12451272 if let result = try ? produceGizmoUsingTechnology () { return result }
12461273 if let result = try ? produceGizmoUsingMagic () { return result }
@@ -1413,7 +1440,7 @@ Swift 2.0
14131440 function or initializer. For example:
14141441
14151442 ```swift
1416- func doSomethingToValues (values : Int ... , options : MyOptions = [], fn : (Int ) -& gt; Void ) { … }
1443+ func doSomethingToValues (values : Int ... , options : MyOptions = [], fn : (Int ) -& gt; Void ) { ... }
14171444 ```
14181445
14191446 ** (20127197 )**
@@ -1445,7 +1472,7 @@ Swift 2.0
14451472 ** (17227475 )**
14461473
14471474* When delegating or chaining to a failable initializer (for example, with
1448- `self .init (… )` or `super .init (… )`), one can now force- unwrap the result with
1475+ `self .init (... )` or `super .init (... )`), one can now force- unwrap the result with
14491476 `! `. For example:
14501477
14511478 ```swift
@@ -2152,7 +2179,7 @@ Swift 1.2
21522179 }
21532180
21542181 class MySomethingDelegate : SomethingDelegate {
2155- @objc func didSomething () { … }
2182+ @objc func didSomething () { ... }
21562183 }
21572184 ```
21582185
0 commit comments