Skip to content

Commit 91180a7

Browse files
authored
Merge branch 'main' into filip-sakel-SE0293-gardening
2 parents f7aecbb + 8b3147c commit 91180a7

File tree

1,215 files changed

+29113
-15774
lines changed

Some content is hidden

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

1,215 files changed

+29113
-15774
lines changed

CHANGELOG.md

Lines changed: 88 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,91 @@
11
CHANGELOG
22
=========
33

4-
<details>
5-
<summary>Note: This is in reverse chronological order, so newer entries are added to the top.</summary>
6-
7-
| Version | Released | Toolchain |
8-
| :--------------------- | :--------- | :---------- |
9-
| [Swift 5.5](#swift-55) | | |
10-
| [Swift 5.4](#swift-54) | | |
11-
| [Swift 5.3](#swift-53) | 2020-09-16 | Xcode 12.0 |
12-
| [Swift 5.2](#swift-52) | 2020-03-24 | Xcode 11.4 |
13-
| [Swift 5.1](#swift-51) | 2019-09-20 | Xcode 11.0 |
14-
| [Swift 5.0](#swift-50) | 2019-03-25 | Xcode 10.2 |
15-
| [Swift 4.2](#swift-42) | 2018-09-17 | Xcode 10.0 |
16-
| [Swift 4.1](#swift-41) | 2018-03-29 | Xcode 9.3 |
17-
| [Swift 4.0](#swift-40) | 2017-09-19 | Xcode 9.0 |
18-
| [Swift 3.1](#swift-31) | 2017-03-27 | Xcode 8.3 |
19-
| [Swift 3.0](#swift-30) | 2016-09-13 | Xcode 8.0 |
20-
| [Swift 2.2](#swift-22) | 2016-03-21 | Xcode 7.3 |
21-
| [Swift 2.1](#swift-21) | 2015-10-21 | Xcode 7.1 |
22-
| [Swift 2.0](#swift-20) | 2015-09-17 | Xcode 7.0 |
23-
| [Swift 1.2](#swift-12) | 2015-04-08 | Xcode 6.3 |
24-
| [Swift 1.1](#swift-11) | 2014-12-02 | Xcode 6.1.1 |
25-
| [Swift 1.0](#swift-10) | 2014-09-15 | Xcode 6.0 |
26-
27-
</details>
4+
_**Note:** This is in reverse chronological order, so newer entries are added to the top._
285

296
Swift 5.5
307
---------
318

9+
* Type names are no longer allowed as an argument to a subscript parameter that expects a metatype type
10+
11+
```swift
12+
struct MyValue {
13+
}
14+
15+
struct MyStruct {
16+
subscript(a: MyValue.Type) -> Int { get { ... } }
17+
}
18+
19+
func test(obj: MyStruct) {
20+
let _ = obj[MyValue]
21+
}
22+
```
23+
24+
Accepting subscripts with `MyValue` as an argument was an oversight because `MyValue` requires explicit `.self`
25+
to reference its metatype, so correct syntax would be to use `obj[MyValue.self]`.
26+
27+
* [SE-0310][]:
28+
29+
Read-only computed properties and subscripts can now define their `get` accessor to be `async` and/or `throws`, by writing one or both of those keywords between the `get` and `{`. Thus, these members can now make asynchronous calls or throw errors in the process of producing a value:
30+
```swift
31+
class BankAccount: FinancialAccount {
32+
var manager: AccountManager?
33+
34+
var lastTransaction: Transaction {
35+
get async throws {
36+
guard manager != nil else { throw BankError.notInYourFavor }
37+
return await manager!.getLastTransaction()
38+
}
39+
}
40+
41+
subscript(_ day: Date) -> [Transaction] {
42+
get async {
43+
return await manager?.getTransactions(onDay: day) ?? []
44+
}
45+
}
46+
}
47+
48+
protocol FinancialAccount {
49+
associatedtype T
50+
var lastTransaction: T { get async throws }
51+
subscript(_ day: Date) -> [T] { get async }
52+
}
53+
```
54+
Accesses to such members, like `lastTransaction` above, will require appropriate marking with `await` and/or `try`:
55+
```swift
56+
extension BankAccount {
57+
func meetsTransactionLimit(_ limit: Amount) async -> Bool {
58+
return try! await self.lastTransaction.amount < limit
59+
// ^~~~~~~~~~~~~~~~ this access is async & throws
60+
}
61+
}
62+
63+
64+
func hadWithdrawlOn(_ day: Date, from acct: BankAccount) async -> Bool {
65+
return await !acct[day].allSatisfy { $0.amount >= Amount.zero }
66+
// ^~~~~~~~~ this access is async
67+
}
68+
```
69+
70+
* [SE-0306][]:
71+
72+
Swift 5.5 includes support for actors, a new kind of type that isolates its instance data to protect it from concurrent access. Accesses to an actor's instance declarations from outside the must be asynchronous:
73+
74+
```swift
75+
actor Counter {
76+
var value = 0
77+
78+
func increment() {
79+
value = value + 1
80+
}
81+
}
82+
83+
func useCounter(counter: Counter) async {
84+
print(await counter.value) // interaction must be async
85+
await counter.increment() // interaction must be async
86+
}
87+
```
88+
3289
* The determination of whether a call to a `rethrows` function can throw now considers default arguments of `Optional` type.
3390

3491
In Swift 5.4, such default arguments were ignored entirely by `rethrows` checking. This meant that the following example was accepted:
@@ -173,11 +230,11 @@ Swift 5.5
173230

174231
The "for" loop can be used to traverse asynchronous sequences in asynchronous code:
175232

176-
```swift
233+
```swift
177234
for try await line in myFile.lines() {
178235
// Do something with each line
179236
}
180-
```
237+
```
181238

182239
Asynchronous for loops use asynchronous sequences, defined by the protocol
183240
`AsyncSequence` and its corresponding `AsyncIterator`.
@@ -187,6 +244,8 @@ Swift 5.5
187244
Swift 5.4
188245
---------
189246

247+
### 2021-04-26 (Xcode 12.5)
248+
190249
* Protocol conformance checking now considers `where` clauses when evaluating if a `typealias` is a suitable witness for an associated type requirement. The following code is now rejected:
191250

192251
```swift
@@ -8429,11 +8488,13 @@ Swift 1.0
84298488
[SE-0284]: <https://github.com/apple/swift-evolution/blob/main/proposals/0284-multiple-variadic-parameters.md>
84308489
[SE-0286]: <https://github.com/apple/swift-evolution/blob/main/proposals/0286-forward-scan-trailing-closures.md>
84318490
[SE-0287]: <https://github.com/apple/swift-evolution/blob/main/proposals/0287-implicit-member-chains.md>
8491+
[SE-0293]: <https://github.com/apple/swift-evolution/blob/main/proposals/0293-extend-property-wrappers-to-function-and-closure-parameters.md>
84328492
[SE-0296]: <https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md>
84338493
[SE-0297]: <https://github.com/apple/swift-evolution/blob/main/proposals/0297-concurrency-objc.md>
84348494
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
84358495
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
8436-
[SE-0293]: <https://github.com/apple/swift-evolution/blob/main/proposals/0293-extend-property-wrappers-to-function-and-closure-parameters.md>
8496+
[SE-0306]: <https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
8497+
[SE-0310]: <https://github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
84378498

84388499
[SR-75]: <https://bugs.swift.org/browse/SR-75>
84398500
[SR-106]: <https://bugs.swift.org/browse/SR-106>

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ macro(configure_sdks_darwin)
108108
set(macosx_arch "x86_64" "arm64")
109109
set(iphoneos_arch "arm64" "arm64e" "armv7")
110110
set(appletvos_arch "arm64")
111-
set(watchos_arch "armv7k")
111+
set(watchos_arch "armv7k" "arm64_32")
112112

113113
set(macosx_ver "10.9")
114114
set(iphoneos_ver "8.0")

cmake/modules/DarwinSDKs.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ endif()
1212

1313
set(SUPPORTED_TVOS_ARCHS "arm64")
1414
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
15-
set(SUPPORTED_WATCHOS_ARCHS "armv7k")
16-
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
15+
set(SUPPORTED_WATCHOS_ARCHS "armv7k;arm64_32")
16+
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
1717
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")
1818

1919
is_sdk_requested(OSX swift_build_osx)

cmake/modules/Libdispatch.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ foreach(sdk ${DISPATCH_SDKS})
101101
# ensure that we strip out the DESTDIR environment
102102
# from the sub-build
103103
${CMAKE_COMMAND} -E env --unset=DESTDIR ${CMAKE_COMMAND} --build . --target install
104+
COMMAND
105+
${CMAKE_COMMAND} -E copy
106+
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}dispatch${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
107+
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}dispatch${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
108+
COMMAND
109+
${CMAKE_COMMAND} -E copy
110+
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
111+
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
104112
STEP_TARGETS
105113
install
106114
BUILD_BYPRODUCTS

cmake/modules/SwiftSetIfArchBitness.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function(set_if_arch_bitness var_name)
1212
"${SIA_ARCH}" STREQUAL "armv6" OR
1313
"${SIA_ARCH}" STREQUAL "armv7" OR
1414
"${SIA_ARCH}" STREQUAL "armv7k" OR
15+
"${SIA_ARCH}" STREQUAL "arm64_32" OR
1516
"${SIA_ARCH}" STREQUAL "armv7s" OR
1617
"${SIA_ARCH}" STREQUAL "wasm32")
1718
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)

docs/ABI/Mangling.rst

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ Globals
147147
// TODO check this::
148148
global ::= mangled-name 'TA' // partial application forwarder
149149
global ::= mangled-name 'Ta' // ObjC partial application forwarder
150-
global ::= mangled-name 'Tw' index // async partial apply thunk for a non-constant function
151150
global ::= mangled-name 'TQ' index // Async await continuation partial function
152151
global ::= mangled-name 'TY' index // Async suspend continuation partial function
153152

@@ -515,13 +514,17 @@ Types
515514

516515
type ::= 'Bb' // Builtin.BridgeObject
517516
type ::= 'BB' // Builtin.UnsafeValueBuffer
518-
type ::= 'Bc' // Builtin.RawUnsafeContinuation
519-
type ::= 'BD' // Builtin.DefaultActorStorage
520-
type ::= 'Be' // Builtin.ExecutorRef
517+
#if SWIFT_RUNTIME_VERSION >= 5.5
518+
type ::= 'Bc' // Builtin.RawUnsafeContinuation
519+
type ::= 'BD' // Builtin.DefaultActorStorage
520+
type ::= 'Be' // Builtin.Executor
521+
#endif
521522
type ::= 'Bf' NATURAL '_' // Builtin.Float<n>
522523
type ::= 'Bi' NATURAL '_' // Builtin.Int<n>
523524
type ::= 'BI' // Builtin.IntLiteral
524-
type ::= 'Bj' // Builtin.Job
525+
#if SWIFT_RUNTIME_VERSION >= 5.5
526+
type ::= 'Bj' // Builtin.Job
527+
#endif
525528
type ::= 'BO' // Builtin.UnknownObject (no longer a distinct type, but still used for AnyObject)
526529
type ::= 'Bo' // Builtin.NativeObject
527530
type ::= 'Bp' // Builtin.RawPointer
@@ -571,19 +574,21 @@ Types
571574
// they are mangled separately as part of the entity.
572575
params-type ::= empty-list // shortcut for no parameters
573576

574-
sendable ::= 'J' // @Sendable on function types
575-
async ::= 'Y' // 'async' annotation on function types
577+
#if SWIFT_RUNTIME_VERSION >= 5.5
578+
async ::= 'Ya' // 'async' annotation on function types
579+
sendable ::= 'Yb' // @Sendable on function types
580+
#endif
576581
throws ::= 'K' // 'throws' annotation on function types
577-
differentiable ::= 'jf' // @differentiable(_forward) on function type
578-
differentiable ::= 'jr' // @differentiable(reverse) on function type
579-
differentiable ::= 'jd' // @differentiable on function type
580-
differentiable ::= 'jl' // @differentiable(_linear) on function type
582+
differentiable ::= 'Yjf' // @differentiable(_forward) on function type
583+
differentiable ::= 'Yjr' // @differentiable(reverse) on function type
584+
differentiable ::= 'Yjd' // @differentiable on function type
585+
differentiable ::= 'Yjl' // @differentiable(_linear) on function type
581586

582587
type-list ::= list-type '_' list-type* // list of types
583588
type-list ::= empty-list
584589

585590
// FIXME: Consider replacing 'h' with a two-char code
586-
list-type ::= type identifier? 'z'? 'h'? 'n'? 'd'? // type with optional label, inout convention, shared convention, owned convention, and variadic specifier
591+
list-type ::= type identifier? 'Yk'? 'z'? 'h'? 'n'? 'd'? // type with optional label, '@noDerivative', inout convention, shared convention, owned convention, and variadic specifier
587592

588593
METATYPE-REPR ::= 't' // Thin metatype representation
589594
METATYPE-REPR ::= 'T' // Thick metatype representation
@@ -667,8 +672,10 @@ mangled in to disambiguate.
667672
COROUTINE-KIND ::= 'A' // yield-once coroutine
668673
COROUTINE-KIND ::= 'G' // yield-many coroutine
669674

670-
SENDABLE ::= 'h' // @Sendable
671-
ASYNC ::= 'H' // @async
675+
#if SWIFT_RUNTIME_VERSION >= 5.5
676+
SENDABLE ::= 'h' // @Sendable
677+
ASYNC ::= 'H' // @async
678+
#endif
672679

673680
PARAM-CONVENTION ::= 'i' // indirect in
674681
PARAM-CONVENTION ::= 'c' // indirect in constant

0 commit comments

Comments
 (0)