Skip to content

Commit f06c6f0

Browse files
authored
Merge branch 'main' into api_checker-py3
2 parents ebe20a4 + f339fdc commit f06c6f0

File tree

1,915 files changed

+68239
-24513
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,915 files changed

+68239
-24513
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,32 @@ docs/_build
4343
# Visual Studio Code Configurations
4444
.vscode
4545

46+
# JetBrains
47+
.idea
48+
4649
# clangd
4750
.cache
4851
.clangd
4952

53+
# SwiftPM
54+
.build
55+
5056
#==============================================================================#
5157
# Ignore CMake temporary files
5258
#==============================================================================#
5359
CMakeCache.txt
5460
CMakeFiles
5561
.atom-build.json
5662

63+
# Generated by JetBrains IDEs
64+
cmake-build-*
65+
5766
#==============================================================================#
5867
# Ignore compile database
5968
#==============================================================================#
6069
compile_commands.json
6170

71+
#==============================================================================#
6272
# Ignore generated GYB files until we fix the workaround on Windows
6373
#==============================================================================#
6474
8

.mailmap

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
Adrian-Constantin Popescu <[email protected]> <[email protected]>
22
3-
43
4+
55
Alexis Beingessner <[email protected]> <[email protected]>
66
77
88
99
Argyrios Kyrtzidis <[email protected]> <[email protected]>
1010
1111
12-
Becca Royal-Gordon <[email protected]> <[email protected]>
1312
Becca Royal-Gordon <[email protected]> <[email protected]>
14-
Becca Royal-Gordon <[email protected]> <[email protected]>
1513
Becca Royal-Gordon <[email protected]> <[email protected]>
14+
Becca Royal-Gordon <[email protected]> <[email protected]>
15+
Becca Royal-Gordon <[email protected]> <[email protected]>
1616
Ben Cohen <[email protected]>
1717
1818
@@ -36,8 +36,8 @@ Dave Abrahams <[email protected]> <[email protected]>
3636
3737
3838
39-
4039
David Rönnqvist <[email protected]>
40+
4141
4242
4343
@@ -87,8 +87,8 @@ Keith Smiley <[email protected]> <[email protected]>
8787
Kevin Saldaña <[email protected]>
8888
Kim Topley <[email protected]>
8989
90-
9190
Kuba Mracek <[email protected]>
91+
9292
9393
9494
Luiz Fernando Silva <[email protected]>
@@ -103,6 +103,7 @@ Max Moiseev <[email protected]> <[email protected]>
103103
104104
105105
106+
106107
107108
108109
@@ -112,8 +113,8 @@ Mishal Shah <[email protected]>
112113
113114
114115
115-
116116
117+
117118
118119
119120
Nicole Jacque <[email protected]>
@@ -128,8 +129,8 @@ Richard Wei <[email protected]> <[email protected]>
128129
129130
130131
131-
132132
Ross Bayer <[email protected]>
133+
133134
134135
135136

CHANGELOG.md

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

66
## Swift 5.7
77

8+
* [SE-0347][]:
9+
10+
It's now possible to use a default value expression with a generic parameter type
11+
to default the argument and its type:
12+
13+
```
14+
func compute<C: Collection>(_ values: C = [0, 1, 2]) {
15+
...
16+
}
17+
```
18+
19+
`compute` is now accepted by compiler and `[Int]` is going to be inferred
20+
for `C` at call sites that do not provide the argument explicitly.
21+
22+
* [SE-0326][]:
23+
24+
It's now possible to infer parameter and result types from the body of a multi-statement
25+
closure. The distinction between single- and multi-statement closures has been removed.
26+
27+
Use of closures becomes less cumbersome by removing the need to constantly specify explicit
28+
closure types which sometimes could be pretty large e.g. when there are multiple parameters
29+
or a complex tuple result type.
30+
31+
For example:
32+
33+
```swift
34+
func map<T>(fn: (Int) -> T) -> T {
35+
return fn(42)
36+
}
37+
38+
func computeResult<U: BinaryInteger>(_: U) -> U { /* processing */ }
39+
40+
let _ = map {
41+
if let $0 < 0 {
42+
// do some processing
43+
}
44+
45+
return computeResult($0)
46+
}
47+
```
48+
49+
The result type of `map` can now be inferred from the body of the trailing closure
50+
passed as an argument.
51+
52+
* [SE-0345][]:
53+
54+
It is now possible to unwrap optional variables with a shorthand syntax that
55+
shadows the existing declaration. For example, the following:
56+
57+
```swift
58+
let foo: String? = "hello world"
59+
60+
if let foo {
61+
print(foo) // prints "hello world"
62+
}
63+
```
64+
65+
is equivalent to:
66+
67+
```swift
68+
let foo: String? = "hello world"
69+
70+
if let foo = foo {
71+
print(foo) // prints "hello world"
72+
}
73+
```
74+
75+
* [SE-0340][]:
76+
77+
It is now possible to make declarations unavailable from use in asynchronous
78+
contexts with the `@available(*, noasync)` attribute.
79+
80+
This is to protect the consumers of an API against undefined behavior that can
81+
occur when the API uses thread-local storage, or encourages using thread-local
82+
storage, across suspension points, or protect developers against holding locks
83+
across suspension points which may lead to undefined behavior, priority
84+
inversions, or deadlocks.
85+
86+
* [SE-0343][]:
87+
88+
Top-level scripts support asynchronous calls.
89+
90+
Using an `await` by calling an asynchronous function or accessing an isolated
91+
variable transitions the top-level to an asynchronous context. As an
92+
asynchronous context, top-level variables are `@MainActor`-isolated and the
93+
top-level is run on the `@MainActor`.
94+
95+
Note that the transition affects function overload resolution and starts an
96+
implicit run loop to drive the concurrency machinery.
97+
98+
Unmodified scripts are not affected by this change unless `-warn-concurrency` is
99+
passed to the compiler invocation. With `-warn-concurrency`, variables in the
100+
top-level are isolated to the main actor and the top-level context is isolated
101+
to the main actor, but is not an asynchronous context.
102+
103+
* [SE-0336][]:
104+
105+
It is now possible to declare `distributed actor` and `distributed func`s inside of them.
106+
107+
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.
108+
109+
Swift does not provide any specific distributed actor system by itself, however, packages in the ecosystem fulfil the role of providing those implementations.
110+
111+
```swift
112+
distributed actor Greeter {
113+
var greetingsSent = 0
114+
115+
distributed func greet(name: String) -> String {
116+
greetingsSent += 1
117+
return "Hello, \(name)!"
118+
}
119+
}
120+
121+
func talkTo(greeter: Greeter) async throws {
122+
// isolation of distributed actors is stronger, it is impossible to refer to
123+
// any stored properties of distributed actors from outside of them:
124+
greeter.greetingsSent // distributed actor-isolated property 'name' can not be accessed from a non-isolated context
125+
126+
// remote calls are implicitly throwing and async,
127+
// to account for the potential networking involved:
128+
let greeting = try await greeter.greet(name: "Alice")
129+
print(greeting) // Hello, Alice!
130+
}
131+
```
132+
8133
* The compiler now emits a warning when a non-final class conforms to a protocol that imposes a same-type requirement between `Self` and an associated type. This is because such a requirement makes the conformance unsound for subclasses.
9134

10-
For example, Swift 5.6 would allow the following code, which at runtime would construct an instanec of `C` and not `SubC` as expected:
135+
For example, Swift 5.6 would allow the following code, which at runtime would construct an instance of `C` and not `SubC` as expected:
11136

12137
```swift
13138
protocol P {
@@ -49,7 +174,7 @@ For example, Swift 5.6 would allow the following code, which at runtime would co
49174

50175
* [SE-0341][]:
51176

52-
Opaque types can now be used in the parameters of functions and subscripts, wher they provide a shorthand syntax for the introduction of a generic parameter. For example, the following:
177+
Opaque types can now be used in the parameters of functions and subscripts, when they provide a shorthand syntax for the introduction of a generic parameter. For example, the following:
53178

54179
```swift
55180
func horizontal(_ v1: some View, _ v2: some View) -> some View {
@@ -110,29 +235,32 @@ For example, Swift 5.6 would allow the following code, which at runtime would co
110235
return [ 1: "One", 2: "Two" ]
111236
}
112237
```
238+
113239
Swift 5.6
114240
---------
115241

116-
* [SE-0327][]:
117-
118-
In Swift 5 mode, a warning is now emitted if the default-value expression of an
119-
instance-member property requires global-actor isolation. For example:
242+
### 2022-03-14 (Xcode 13.3)
120243

121-
```swift
122-
@MainActor
123-
func partyGenerator() -> [PartyMember] { fatalError("todo") }
244+
* [SE-0327][]:
124245

125-
class Party {
126-
@MainActor var members: [PartyMember] = partyGenerator()
127-
// ^~~~~~~~~~~~~~~~
128-
// warning: expression requiring global actor 'MainActor' cannot
129-
// appear in default-value expression of property 'members'
130-
}
131-
```
246+
In Swift 5 mode, a warning is now emitted if the default-value expression of an
247+
instance-member property requires global-actor isolation. For example:
132248

133-
Previously, the isolation granted by the type checker matched the isolation of
134-
the property itself, but at runtime that is not guaranteed. In Swift 6,
135-
such default-value expressions will become an error if they require isolation.
249+
```swift
250+
@MainActor
251+
func partyGenerator() -> [PartyMember] { fatalError("todo") }
252+
253+
class Party {
254+
@MainActor var members: [PartyMember] = partyGenerator()
255+
// ^~~~~~~~~~~~~~~~
256+
// warning: expression requiring global actor 'MainActor' cannot
257+
// appear in default-value expression of property 'members'
258+
}
259+
```
260+
261+
Previously, the isolation granted by the type checker matched the isolation of
262+
the property itself, but at runtime that is not guaranteed. In Swift 6,
263+
such default-value expressions will become an error if they require isolation.
136264

137265
* Actor isolation checking now understands that `defer` bodies share the isolation of their enclosing function.
138266

@@ -341,8 +469,6 @@ such default-value expressions will become an error if they require isolation.
341469
}
342470
```
343471

344-
**Add new entries to the top of this section, not here!**
345-
346472
Swift 5.5
347473
---------
348474

@@ -761,8 +887,6 @@ Swift 5.5
761887
Asynchronous for loops use asynchronous sequences, defined by the protocol
762888
`AsyncSequence` and its corresponding `AsyncIterator`.
763889

764-
**Add new entries to the top of this section, not here!**
765-
766890
Swift 5.4
767891
---------
768892

@@ -929,8 +1053,6 @@ Swift 5.4
9291053
let _: Foo? = .bar.anotherFoo.getFoo().optionalFoo?.optionalFoo![]
9301054
```
9311055

932-
**Add new entries to the top of this section, not here!**
933-
9341056
Swift 5.3
9351057
---------
9361058

@@ -9034,6 +9156,12 @@ Swift 1.0
90349156
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
90359157
[SE-0335]: <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
90369158
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
9159+
[SE-0336]: <https://github.com/apple/swift-evolution/blob/main/proposals/0336-distributed-actor-isolation.md>
9160+
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
9161+
[SE-0340]: <https://github.com/apple/swift-evolution/blob/main/proposals/0340-swift-noasync.md>
9162+
[SE-0345]: <https://github.com/apple/swift-evolution/blob/main/proposals/0345-if-let-shorthand.md>
9163+
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
9164+
[SE-0347]: <https://github.com/apple/swift-evolution/blob/main/proposals/0347-type-inference-from-default-exprs.md>
90379165

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

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ option(SWIFT_BUILD_PERF_TESTSUITE
137137
"Create in-tree targets for building swift performance benchmarks."
138138
FALSE)
139139

140+
option(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER
141+
"Build the Swift regex parser as part of the compiler."
142+
TRUE)
143+
140144
option(SWIFT_INCLUDE_TESTS "Create targets for building/running tests." TRUE)
141145

142146
option(SWIFT_INCLUDE_TEST_BINARIES
@@ -327,9 +331,15 @@ option(SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS
327331
"If non-empty, when embedding the LLVM bitcode binary sections into the relevant binaries, pass in -bitcode_hide_symbols. Does nothing if SWIFT_EMBED_BITCODE_SECTION is set to false."
328332
FALSE)
329333

334+
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
335+
set(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT_default TRUE)
336+
else()
337+
set(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT_default FALSE)
338+
endif()
339+
330340
option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
331341
"Whether to enable CrashReporter integration"
332-
FALSE)
342+
"${SWIFT_RUNTIME_CRASH_REPORTER_CLIENT_default}")
333343

334344
set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
335345
"The name of the toolchain to pass to 'xcrun'")

0 commit comments

Comments
 (0)