Skip to content

[5.7][ChangeLog] synchronize with main #42556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 64 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ _**Note:** This is in reverse chronological order, so newer entries are added to

## Swift 5.7

* 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:

```swift
class Object {
@objc func getTag() -> Int
}

@objc protocol P {
@objc optional func didUpdateObject(withTag tag: Int)
}

let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag

let didUpdateObject: (any P) -> ((Int) -> Void)? = P.didUpdateObject
```

* [SE-0349][]:

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

* 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:
* [SE-0334][]:

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

@objc protocol P {
@objc optional func didUpdateObject(withTag tag: Int)
}
```swift
extension UnsafeRawPointer {
public func alignedUp<T>(for: T.type) -> UnsafeRawPointer
public func alignedDown<T>(for: T.type) -> UnsafeRawPointer
public func alignedUp(toMultipleOf alignment: Int) -> UnsafeRawPointer
public func alignedDown(toMultipleOf alignment: Int) -> UnsafeRawPointer
}
```
- It is now possible to use a pointer to `struct` to obtain a pointer to one
of its stored properties:

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

let didUpdateObject: (any P) -> ((Int) -> Void)? = P.didUpdateObject
```
* [SE-0333][]:

It is now possible to use the `withMemoryRebound<T>()` method on raw memory,
that is `UnsafeRawPointer` , `UnsafeRawBufferPointer` and their mutable
counterparts. Additionally, we clarified the semantics of
`withMemoryRebound<T>()` when used on typed memory (`UnsafePointer<Pointee>`,
`UnsafeBufferPointer<Pointee>` and their mutable counterparts). Whereas
`Pointee` and `T` were previously required to have the same stride, you can
now rebind in cases where `Pointee` is an aggregate of `T` or vice-versa. For
example, given an `UnsafeMutableBufferPointer<CGPoint>`, you can now use
`withMemoryRebound` to operate temporarily on a
`UnsafeMutableBufferPointer<CGFloat>`, because `CGPoint` is an aggregate of
`CGFloat`.

* [SE-0352][]:

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

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.

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

```swift
distributed actor Greeter {
Expand Down Expand Up @@ -297,9 +339,12 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
return [ 1: "One", 2: "Two" ]
}
```

Swift 5.6
---------

### 2022-03-14 (Xcode 13.3)

* [SE-0327][]:

In Swift 5 mode, a warning is now emitted if the default-value expression of an
Expand Down Expand Up @@ -528,8 +573,6 @@ Swift 5.6
}
```

**Add new entries to the top of this section, not here!**

Swift 5.5
---------

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

**Add new entries to the top of this section, not here!**

Swift 5.4
---------

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

**Add new entries to the top of this section, not here!**

Swift 5.3
---------

Expand Down Expand Up @@ -9213,19 +9252,21 @@ Swift 1.0
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
[SE-0320]: <https://github.com/apple/swift-evolution/blob/main/proposals/0320-codingkeyrepresentable.md>
[SE-0322]: <https://github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
[SE-0323]: <https://github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
[SE-0327]: <https://github.com/apple/swift-evolution/blob/main/proposals/0327-actor-initializers.md>
[SE-0328]: <https://github.com/apple/swift-evolution/blob/main/proposals/0328-structural-opaque-result-types.md>
[SE-0331]: <https://github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
[SE-0333]: <https://github.com/apple/swift-evolution/blob/main/proposals/0333-with-memory-rebound.md>
[SE-0334]: <https://github.com/apple/swift-evolution/blob/main/proposals/0334-pointer-usability-improvements.md>
[SE-0335]: <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
[SE-0336]: <https://github.com/apple/swift-evolution/blob/main/proposals/0336-distributed-actor-isolation.md>
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
[SE-0340]: <https://github.com/apple/swift-evolution/blob/main/proposals/0340-swift-noasync.md>
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
[SE-0345]: <https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md>
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
[SE-0347]: <https://github.com/apple/swift-evolution/blob/main/proposals/0347-type-inference-from-default-exprs.md>
[SE-0349]: <https://github.com/apple/swift-evolution/blob/main/proposals/0349-unaligned-loads-and-stores.md>
[SE-0352]: <https://github.com/apple/swift-evolution/blob/main/proposals/0352-implicit-open-existentials.md>
Expand Down