Skip to content

Commit c1fcf45

Browse files
authored
Merge pull request #42556 from glessard/changelog-updates
[5.7][ChangeLog] synchronize with main
2 parents 85e2a7b + a87aad5 commit c1fcf45

File tree

1 file changed

+64
-23
lines changed

1 file changed

+64
-23
lines changed

CHANGELOG.md

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on the `AnyObject` metatype are now supported. These references always have the type of a function that accepts a single argument and returns an optional value of function type:
9+
10+
```swift
11+
class Object {
12+
@objc func getTag() -> Int
13+
}
14+
15+
@objc protocol P {
16+
@objc optional func didUpdateObject(withTag tag: Int)
17+
}
18+
19+
let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag
20+
21+
let didUpdateObject: (any P) -> ((Int) -> Void)? = P.didUpdateObject
22+
```
23+
824
* [SE-0349][]:
925

1026
Loading data from raw memory represented by `UnsafeRawPointer`,
@@ -29,21 +45,47 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
2945
alignment restriction lifted, so that storing to arbitrary offsets of raw
3046
memory can now succeed.
3147

32-
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on the `AnyObject` metatype are now supported. These references always have the type of a function that accepts a single argument and returns an optional value of function type:
48+
* [SE-0334][]:
3349

34-
```swift
35-
class Object {
36-
@objc func getTag() -> Int
37-
}
50+
- `UnsafeRawPointer` and `UnsafeMutableRawPointer` have new functionality for
51+
pointer arithmetic, adding functions to obtain a pointer advanced to the next
52+
or previous alignment boundary:
3853

39-
@objc protocol P {
40-
@objc optional func didUpdateObject(withTag tag: Int)
41-
}
54+
```swift
55+
extension UnsafeRawPointer {
56+
public func alignedUp<T>(for: T.type) -> UnsafeRawPointer
57+
public func alignedDown<T>(for: T.type) -> UnsafeRawPointer
58+
public func alignedUp(toMultipleOf alignment: Int) -> UnsafeRawPointer
59+
public func alignedDown(toMultipleOf alignment: Int) -> UnsafeRawPointer
60+
}
61+
```
62+
- It is now possible to use a pointer to `struct` to obtain a pointer to one
63+
of its stored properties:
4264

43-
let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag
65+
```swift
66+
withUnsafeMutablePointer(to: &myStruct) {
67+
let interiorPointer = $0.pointer(to: \.myProperty)!
68+
return myCFunction(interiorPointer)
69+
}
70+
```
71+
- Comparisons between pointers have been simplified by being more permissive.
72+
Since pointers are representations of memory locations within a single pool of
73+
underlying memory, Swift now allows comparing pointers without requiring type
74+
conversions with the `==`, `!=`, `<`,`<=`,`>`, and `>=` operators.
4475

45-
let didUpdateObject: (any P) -> ((Int) -> Void)? = P.didUpdateObject
46-
```
76+
* [SE-0333][]:
77+
78+
It is now possible to use the `withMemoryRebound<T>()` method on raw memory,
79+
that is `UnsafeRawPointer` , `UnsafeRawBufferPointer` and their mutable
80+
counterparts. Additionally, we clarified the semantics of
81+
`withMemoryRebound<T>()` when used on typed memory (`UnsafePointer<Pointee>`,
82+
`UnsafeBufferPointer<Pointee>` and their mutable counterparts). Whereas
83+
`Pointee` and `T` were previously required to have the same stride, you can
84+
now rebind in cases where `Pointee` is an aggregate of `T` or vice-versa. For
85+
example, given an `UnsafeMutableBufferPointer<CGPoint>`, you can now use
86+
`withMemoryRebound` to operate temporarily on a
87+
`UnsafeMutableBufferPointer<CGFloat>`, because `CGPoint` is an aggregate of
88+
`CGFloat`.
4789

4890
* [SE-0352][]:
4991

@@ -168,7 +210,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
168210

169211
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.
170212

171-
Swift does not provide any specific distributed actor system by itself, however, packages in the ecosystem fulfil the role of providing those implementations.
213+
Swift does not provide any specific distributed actor system by itself, however, packages in the ecosystem fulfill the role of providing those implementations.
172214

173215
```swift
174216
distributed actor Greeter {
@@ -297,9 +339,12 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
297339
return [ 1: "One", 2: "Two" ]
298340
}
299341
```
342+
300343
Swift 5.6
301344
---------
302345

346+
### 2022-03-14 (Xcode 13.3)
347+
303348
* [SE-0327][]:
304349

305350
In Swift 5 mode, a warning is now emitted if the default-value expression of an
@@ -528,8 +573,6 @@ Swift 5.6
528573
}
529574
```
530575

531-
**Add new entries to the top of this section, not here!**
532-
533576
Swift 5.5
534577
---------
535578

@@ -948,8 +991,6 @@ Swift 5.5
948991
Asynchronous for loops use asynchronous sequences, defined by the protocol
949992
`AsyncSequence` and its corresponding `AsyncIterator`.
950993

951-
**Add new entries to the top of this section, not here!**
952-
953994
Swift 5.4
954995
---------
955996

@@ -1116,8 +1157,6 @@ Swift 5.4
11161157
let _: Foo? = .bar.anotherFoo.getFoo().optionalFoo?.optionalFoo![]
11171158
```
11181159

1119-
**Add new entries to the top of this section, not here!**
1120-
11211160
Swift 5.3
11221161
---------
11231162

@@ -9213,19 +9252,21 @@ Swift 1.0
92139252
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
92149253
[SE-0320]: <https://github.com/apple/swift-evolution/blob/main/proposals/0320-codingkeyrepresentable.md>
92159254
[SE-0322]: <https://github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
9216-
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
92179255
[SE-0323]: <https://github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
9256+
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
9257+
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
92189258
[SE-0327]: <https://github.com/apple/swift-evolution/blob/main/proposals/0327-actor-initializers.md>
92199259
[SE-0328]: <https://github.com/apple/swift-evolution/blob/main/proposals/0328-structural-opaque-result-types.md>
92209260
[SE-0331]: <https://github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
9221-
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
9261+
[SE-0333]: <https://github.com/apple/swift-evolution/blob/main/proposals/0333-with-memory-rebound.md>
9262+
[SE-0334]: <https://github.com/apple/swift-evolution/blob/main/proposals/0334-pointer-usability-improvements.md>
92229263
[SE-0335]: <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
9223-
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
92249264
[SE-0336]: <https://github.com/apple/swift-evolution/blob/main/proposals/0336-distributed-actor-isolation.md>
9225-
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
9265+
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
92269266
[SE-0340]: <https://github.com/apple/swift-evolution/blob/main/proposals/0340-swift-noasync.md>
9267+
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
9268+
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
92279269
[SE-0345]: <https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md>
9228-
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
92299270
[SE-0347]: <https://github.com/apple/swift-evolution/blob/main/proposals/0347-type-inference-from-default-exprs.md>
92309271
[SE-0349]: <https://github.com/apple/swift-evolution/blob/main/proposals/0349-unaligned-loads-and-stores.md>
92319272
[SE-0352]: <https://github.com/apple/swift-evolution/blob/main/proposals/0352-implicit-open-existentials.md>

0 commit comments

Comments
 (0)