Skip to content

Commit d7c1ff8

Browse files
committed
Merge branch 'main' of github.com:apple/swift into maxd/main-merge
# Conflicts: # stdlib/public/Concurrency/TaskGroup.swift # test/stdlib/Runtime.swift.gyb
2 parents 4be9673 + 53069e2 commit d7c1ff8

File tree

510 files changed

+20873
-7610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+20873
-7610
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Dave <[email protected]>
3535
3636
3737
38-
Dave Lee <davelee@lyft.com> <davelee.com@gmail.com>
38+
Dave Lee <davelee.com@gmail.com> <davelee@lyft.com>
3939
4040
David Rönnqvist <[email protected]>
4141

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ Swift Next
7575
}
7676
```
7777

78+
* [SE-0297][]:
79+
80+
An Objective-C method that delivers its results asynchronously via a completion handler block will be translated into an `async` method that directly returns the result (or throws). For example, the following Objective-C method from [CloudKit](https://developer.apple.com/documentation/cloudkit/ckcontainer/1640387-fetchshareparticipantwithuserrec):
81+
82+
```objc
83+
- (void)fetchShareParticipantWithUserRecordID:(CKRecordID *)userRecordID
84+
completionHandler:(void (^)(CKShareParticipant * _Nullable, NSError * _Nullable))completionHandler;
85+
```
86+
87+
will be translated into an `async throws` method that returns the participant instance:
88+
89+
```swift
90+
func fetchShareParticipant(
91+
withUserRecordID userRecordID: CKRecord.ID
92+
) async throws -> CKShare.Participant
93+
```
94+
95+
Swift callers can invoke this `async` method within an `await` expression:
96+
97+
```swift
98+
guard let participant = try? await container.fetchShareParticipant(withUserRecordID: user) else {
99+
return nil
100+
}
101+
```
102+
78103
* [SE-0298][]:
79104

80105
The "for" loop can be used to traverse asynchronous sequences in asynchronous code:
@@ -8336,6 +8361,7 @@ Swift 1.0
83368361
[SE-0286]: <https://github.com/apple/swift-evolution/blob/main/proposals/0286-forward-scan-trailing-closures.md>
83378362
[SE-0287]: <https://github.com/apple/swift-evolution/blob/main/proposals/0287-implicit-member-chains.md>
83388363
[SE-0296]: <https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md>
8364+
[SE-0297]: <https://github.com/apple/swift-evolution/blob/main/proposals/0297-concurrency-objc.md>
83398365
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
83408366

83418367
[SR-75]: <https://bugs.swift.org/browse/SR-75>

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ option(USE_SWIFT_ASYNC_LOWERING
201201
functions if it is supported for the target. The runtime also checks
202202
this setting before using async-specific attributes. This only applies
203203
to the async calling convention and not to the async context attribute."
204-
FALSE)
204+
TRUE)
205205

206206
#
207207
# User-configurable Swift Standard Library specific options.

benchmark/single-source/Differentiation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public func run_DifferentiationIdentity(N: Int) {
4040
x
4141
}
4242
for _ in 0..<1000*N {
43-
blackHole(valueWithGradient(at: 1, in: f))
43+
blackHole(valueWithGradient(at: 1, of: f))
4444
}
4545
}
4646

@@ -50,7 +50,7 @@ public func run_DifferentiationSquare(N: Int) {
5050
x * x
5151
}
5252
for _ in 0..<1000*N {
53-
blackHole(valueWithGradient(at: 1, in: f))
53+
blackHole(valueWithGradient(at: 1, of: f))
5454
}
5555
}
5656

@@ -66,7 +66,7 @@ public func run_DifferentiationArraySum(N: Int) {
6666
return result
6767
}
6868
for _ in 0..<N {
69-
blackHole(valueWithGradient(at: onesArray, in: sum))
69+
blackHole(valueWithGradient(at: onesArray, of: sum))
7070
}
7171
}
7272

benchmark/single-source/Substring.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public let SubstringTest = [
2929
BenchmarkInfo(name: "SubstringEquatable", runFunction: run_SubstringEquatable, tags: [.validation, .api, .String]),
3030
BenchmarkInfo(name: "SubstringFromLongString", runFunction: run_SubstringFromLongString, tags: [.validation, .api, .String]),
3131
BenchmarkInfo(name: "SubstringFromLongStringGeneric", runFunction: run_SubstringFromLongStringGeneric, tags: [.validation, .api, .String]),
32+
BenchmarkInfo(name: "SubstringTrimmingASCIIWhitespace", runFunction: run_SubstringTrimmingASCIIWhitespace, tags: [.validation, .api, .String]),
3233
]
3334

3435
// A string that doesn't fit in small string storage and doesn't fit in Latin-1
@@ -267,6 +268,38 @@ public func run_SubstringComparable(_ N: Int) {
267268
CheckResults(count == N*500)
268269
}
269270

271+
extension Character {
272+
fileprivate var isASCIIWhitespace: Bool {
273+
return self == " " || self == "\t" || self == "\r" || self == "\n" || self == "\r\n"
274+
}
275+
}
276+
277+
extension Substring {
278+
fileprivate func trimWhitespace() -> Substring {
279+
var me = self
280+
while me.first?.isASCIIWhitespace == .some(true) {
281+
me = me.dropFirst()
282+
}
283+
while me.last?.isASCIIWhitespace == .some(true) {
284+
me = me.dropLast()
285+
}
286+
return me
287+
}
288+
}
289+
290+
let _trimmableSubstrings = "pineapple,🍍, pineapple\t,\r\n\r\n\r\n, 🍍 ,".split(separator: ",")
291+
292+
@inline(never)
293+
public func run_SubstringTrimmingASCIIWhitespace(_ N: Int) {
294+
let substrings = _trimmableSubstrings // bringing this alias from above
295+
var count = 0
296+
for _ in 1...N*100 {
297+
for substring in substrings {
298+
blackHole(substring.trimWhitespace())
299+
}
300+
}
301+
}
302+
270303
/*
271304
func checkLess<T, U>(_ x: T, _ y: U)
272305
where T : StringProtocol, U : StringProtocol {

docs/ABI/Mangling.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ types where the metadata itself has unknown layout.)
222222
global ::= global 'Tm' // merged function
223223
global ::= entity // some identifiable thing
224224
global ::= from-type to-type generic-signature? 'TR' // reabstraction thunk
225-
global ::= impl-function-type type 'Tz' // objc-to-swift-async completion handler block implementation
226-
global ::= impl-function-type type 'TZ' // objc-to-swift-async completion handler block implementation (predefined by runtime)
225+
global ::= impl-function-type type 'Tz' index? // objc-to-swift-async completion handler block implementation
226+
global ::= impl-function-type type 'TZ' index? // objc-to-swift-async completion handler block implementation (predefined by runtime)
227227
global ::= from-type to-type generic-signature? 'TR' // reabstraction thunk
228228
global ::= impl-function-type type generic-signature? 'Tz' // objc-to-swift-async completion handler block implementation
229229
global ::= impl-function-type type generic-signature? 'TZ' // objc-to-swift-async completion handler block implementation (predefined by runtime)
@@ -325,6 +325,7 @@ Entities
325325
entity-spec ::= 'fA' INDEX // default argument N+1 generator
326326
entity-spec ::= 'fi' // non-local variable initializer
327327
entity-spec ::= 'fP' // property wrapper backing initializer
328+
entity-spec ::= 'fW' // property wrapper init from projected value
328329
entity-spec ::= 'fD' // deallocating destructor; untyped
329330
entity-spec ::= 'fd' // non-deallocating destructor; untyped
330331
entity-spec ::= 'fE' // ivar destroyer; untyped

0 commit comments

Comments
 (0)