Skip to content

Commit 8eef50f

Browse files
committed
Merge branch 'master' into unicode-properties
2 parents 54f4c77 + 0a46b4b commit 8eef50f

File tree

3,205 files changed

+142581
-130492
lines changed

Some content is hidden

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

3,205 files changed

+142581
-130492
lines changed

.mailmap

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
Adrian-Constantin Popescu <[email protected]> <[email protected]>
2+
3+
4+
5+
Alexis Beingessner <[email protected]> <[email protected]>
6+
7+
8+
9+
Argyrios Kyrtzidis <[email protected]> <[email protected]>
10+
11+
Ben Cohen <[email protected]>
12+
13+
14+
15+
Brent Royal-Gordon <[email protected]> <[email protected]>
16+
17+
18+
19+
20+
Chris Bieneman <[email protected]>
21+
22+
23+
24+
25+
26+
codester <[email protected]> codestergit <[email protected]>
27+
28+
29+
Dante Broggi <[email protected]>
30+
31+
32+
33+
34+
35+
36+
37+
David Rönnqvist <[email protected]>
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
Erik Eckstein <[email protected]>
49+
50+
51+
Ewa Matejska <[email protected]>
52+
53+
54+
55+
56+
57+
58+
59+
Greg Titus <[email protected]>
60+
61+
62+
63+
64+
65+
Hitster GTD <[email protected]>
66+
67+
Ingmar Stein <[email protected]>
68+
69+
Jacob Bandes-Storch <[email protected]> <[email protected]>
70+
71+
Janosch Hildebrand <[email protected]> <[email protected]>
72+
Janosch Hildebrand <[email protected]> <[email protected]>
73+
74+
75+
76+
77+
joe DeCapo <[email protected]>
78+
79+
80+
81+
82+
83+
84+
85+
86+
Kevin Saldaña <[email protected]>
87+
Kim Topley <[email protected]>
88+
89+
90+
Kuba Mracek <[email protected]>
91+
Luiz Fernando Silva <[email protected]>
92+
93+
94+
95+
96+
97+
Max Moiseev <[email protected]>
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
Mishal Awadah <[email protected]>
108+
Mishal Shah <[email protected]>
109+
110+
111+
112+
113+
114+
115+
116+
Nicole Jacque <[email protected]>
117+
118+
119+
120+
Paweł Szot <[email protected]>
121+
122+
Pete Cooper <[email protected]>
123+
124+
125+
126+
127+
128+
129+
Ross Bayer <[email protected]>
130+
131+
132+
133+
134+
135+
Stephen Canon <[email protected]>
136+
137+
Sukolsak Sakshuwong <[email protected]>
138+
139+
140+
141+
142+
143+
144+
145+
146+

CHANGELOG.md

Lines changed: 185 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Swift 5.0
3333
class Node {
3434
var children = [Node]()
3535

36-
var depth: Int {
36+
var depth: Int = 0 {
3737
didSet {
3838
if depth < 0 {
3939
// Will not recursively call didSet, as setting depth on self (same
@@ -49,10 +49,6 @@ Swift 5.0
4949
}
5050
}
5151
}
52-
53-
init(depth: Int) {
54-
self.depth = depth
55-
}
5652
}
5753
```
5854

@@ -61,6 +57,165 @@ Swift 5.0
6157
Swift 4.2
6258
---------
6359

60+
* [SE-0194][]
61+
62+
The new CaseIterable protocol describes types which have a static
63+
“allCases” property that is used to describe all of the cases of the
64+
type. Swift will synthesize this “allCases” property for enums that
65+
have no associated values. For example:
66+
67+
```swift
68+
enum Suit: CaseIterable {
69+
case heart
70+
case club
71+
case diamond
72+
case spade
73+
}
74+
75+
print(Suit.allCases) // prints [Suit.heart, Suit.club, Suit.diamond, Suit.spade]
76+
```
77+
78+
* [SE-0185][]
79+
80+
Protocol conformances are now able to be synthesized in extensions in the same
81+
file as the type definition, allowing automatic synthesis of conditional
82+
conformances to `Hashable`, `Equatable` and `Codable` (both `Encodable` and
83+
`Decodable`). For instance, if there is a generic wrapper type that can only
84+
be `Equatable` when its wrapped type is also `Equatable`, the `==` method can
85+
be automatically constructed by the compiler:
86+
87+
```swift
88+
struct Generic<Param> {
89+
var property: Param
90+
}
91+
92+
extension Generic: Equatable where Param: Equatable {}
93+
// Automatically synthesized inside the extension:
94+
// static func ==(lhs: Generic, rhs: Generic) -> Bool {
95+
// return lhs.property == rhs.property
96+
// }
97+
```
98+
99+
Code that wants to be as precise as possible should generally not
100+
conditionally conform to `Codable` directly, but rather its two constituent
101+
protocols `Encodable` and `Decodable`, or else one can only (for instance)
102+
decode a `Generic<Param>` if `Param` is `Encodable` in addition to
103+
`Decodable`, even though `Encodable` is likely not required:
104+
105+
```swift
106+
// Unnecessarily restrictive:
107+
extension Generic: Codable where Param: Codable {}
108+
109+
// More precise:
110+
extension Generic: Encodable where Param: Encodable {}
111+
extension Generic: Decodable where Param: Decodable {}
112+
```
113+
114+
Finally, due to `Decodable` having an `init` requirement, it is not possible
115+
to conform to `Decodable` in an extension of a non-final class: such a class
116+
needs to have any `init`s from protocols be `required`, which means they need
117+
to be in the class definition.
118+
119+
120+
* [SE-0054][]
121+
122+
`ImplicitlyUnwrappedOptional<T>` is now an unavailable typealias of `Optional<T>`.
123+
Declarations annotated with `!` have the type `Optional<T>`. If an
124+
expression involving one of these values will not compile successfully with the
125+
type `Optional<T>`, it is implicitly unwrapped, producing a value of type `T`.
126+
127+
In some cases this change will cause code that previously compiled to
128+
need to be adjusted. Please see [this blog post](https://swift.org/blog/iuo/)
129+
for more information.
130+
131+
* [SE-0206][]
132+
133+
The standard library now uses a high-quality, randomly seeded, universal
134+
hash function, represented by the new public `Hasher` struct.
135+
136+
“Random seeding” varies the result of `hashValue` on each execution of a
137+
Swift program, improving the reliability of the standard library's hashed
138+
collections such as `Set` and `Dictionary`. In particular, random seeding
139+
enables better protection against (accidental or deliberate) hash-flooding
140+
attacks.
141+
142+
This change fulfills a long-standing prophecy in Hashable's documentation:
143+
144+
> Hash values are not guaranteed to be equal across different executions of
145+
> your program. Do not save hash values to use during a future execution.
146+
147+
As a consequence of random seeding, the elements in `Set` and `Dictionary`
148+
values may have a different order on each execution. This may expose some
149+
bugs in existing code that accidentally relies on repeatable ordering.
150+
151+
Additionally, the `Hashable` protocol now includes an extra function
152+
requirement, `hash(into:)`. The new requirement is designed to be much
153+
easier to implement than the old `hashValue` property, and it generally
154+
provides better hashing. To implement `hash(into:)`, simply feed the exact
155+
same components of your type that you compare in `Equatable`'s `==`
156+
implementation to the supplied `Hasher`:
157+
158+
```swift
159+
struct Foo: Hashable {
160+
var a: String?
161+
var b: [Int]
162+
var c: [String: Int]
163+
164+
static func ==(lhs: Foo, rhs: Foo) -> Bool {
165+
return lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c
166+
}
167+
168+
func hash(into hasher: inout Hasher) {
169+
hasher.combine(a)
170+
hasher.combine(b)
171+
hasher.combine(c)
172+
}
173+
}
174+
```
175+
176+
Automatic synthesis for `Hashable` ([SE-0185]) has been updated to generate
177+
`hash(into:)` implementations. For example, the `==` and `hash(into:)`
178+
implementations above are equivalent to the ones synthesized by the
179+
compiler, and can be removed without changing the meaning of the code.
180+
181+
Synthesis has also been extended to support deriving `hashValue` from
182+
`hash(into:)`, and vice versa. Therefore, code that only implements
183+
`hashValue` continues to work in Swift 4.2. This new compiler functionality
184+
works for all types that can implement `Hashable`, including classes.
185+
186+
Note that these changes don't affect Foundation's hashing interface. Classes
187+
that subclass `NSObject` should override the `hash` property, like before.
188+
189+
In certain controlled environments, such as while running particular tests,
190+
it may be helpful to selectively disable hash seed randomization, so that
191+
hash values and the order of elements in `Set`/`Dictionary` values remain
192+
consistent across executions. You can disable hash seed randomization by
193+
defining the environment variable `SWIFT_DETERMINISTIC_HASHING` with the
194+
value of `1`. The Swift runtime looks at this variable during process
195+
startup and, if it is defined, replaces the random seed with a constant
196+
value.
197+
198+
* [SR-106][]
199+
200+
The behavior of `.description` and `.debugDescription` for floating-point
201+
numbers has been changed. Previously these unconditionally printed a fixed
202+
number of decimal digits (e.g. 15 and 17 for Double, respectively). They now
203+
print exactly as many digits as are needed for the resulting string to
204+
convert back to the original source value, and no more. For more details,
205+
see the original bug report and the linked pull request.
206+
207+
* [SE-0193][]
208+
209+
Various function-like declarations can now be marked as `@inlinable`,
210+
making their bodies available for optimizations from other modules.
211+
212+
Inlinable function bodies must only reference public declarations, unless
213+
the referenced declaration is marked as `@usableFromInline`.
214+
215+
Note that the presence of the attribute itself does not force inlining or
216+
any other optimization to be performed, nor does it have any effect on
217+
optimizations performed within a single module.
218+
64219
* The C `long double` type is now imported as `Float80` on i386 and x86_64
65220
macOS and Linux. The tgmath functions in the Darwin and glibc modules now
66221
 support `Float80` as well as `Float` and `Double`. Several tgmath
@@ -70,11 +225,10 @@ Swift 4.2
70225
* [SE-0143][]
71226

72227
The standard library types `Optional`, `Array`, `ArraySlice`,
73-
`ContiguousArray`, `Dictionary`, `DictionaryLiteral`, `Range`, and
74-
`ClosedRange` now conform to the `Hashable` protocol when their element or
75-
bound types (as the case may be) conform to `Hashable`. This makes
76-
synthesized `Hashable` implementations available for types that include stored
77-
properties of these types.
228+
`ContiguousArray`, `Dictionary`, `Range`, and `ClosedRange` now conform to the
229+
`Hashable` protocol when their element or bound types (as the case may be)
230+
conform to `Hashable`. This makes synthesized `Hashable` implementations
231+
available for types that include stored properties of these types.
78232

79233
* [SE-0196][]
80234

@@ -103,16 +257,18 @@ Swift 4.2
103257

104258
* [SE-0143][]
105259

106-
Runtime query of conditional conformances is now implemented. Therefore,
107-
a dynamic cast such as `value as? P`, where the dynamic type of `value`
108-
conditionally conforms to `P`, will succeed when the conditional
109-
requirements are met.
260+
Runtime query of conditional conformances is now implemented. Therefore,
261+
a dynamic cast such as `value as? P`, where the dynamic type of `value`
262+
conditionally conforms to `P`, will succeed when the conditional
263+
requirements are met.
110264

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

113267
Swift 4.1
114268
---------
115269

270+
### 2018-03-29 (Xcode 9.3)
271+
116272
* [SE-0075][]
117273

118274
Compile-time testing for the existence and importability of modules is now
@@ -6968,7 +7124,21 @@ Swift 1.0
69687124
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
69697125
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
69707126
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>
6971-
7127+
[SE-0200]: <https://github.com/apple/swift-evolution/blob/master/proposals/0200-raw-string-escaping.md>
7128+
[SE-0201]: <https://github.com/apple/swift-evolution/blob/master/proposals/0201-package-manager-local-dependencies.md>
7129+
[SE-0202]: <https://github.com/apple/swift-evolution/blob/master/proposals/0202-random-unification.md>
7130+
[SE-0203]: <https://github.com/apple/swift-evolution/blob/master/proposals/0203-rename-sequence-elements-equal.md>
7131+
[SE-0204]: <https://github.com/apple/swift-evolution/blob/master/proposals/0204-add-last-methods.md>
7132+
[SE-0205]: <https://github.com/apple/swift-evolution/blob/master/proposals/0205-withUnsafePointer-for-lets.md>
7133+
[SE-0206]: <https://github.com/apple/swift-evolution/blob/master/proposals/0206-hashable-enhancements.md>
7134+
[SE-0207]: <https://github.com/apple/swift-evolution/blob/master/proposals/0207-containsOnly.md>
7135+
[SE-0208]: <https://github.com/apple/swift-evolution/blob/master/proposals/0208-package-manager-system-library-targets.md>
7136+
[SE-0209]: <https://github.com/apple/swift-evolution/blob/master/proposals/0209-package-manager-swift-lang-version-update.md>
7137+
[SE-0210]: <https://github.com/apple/swift-evolution/blob/master/proposals/0210-key-path-offset.md>
7138+
[SE-0211]: <https://github.com/apple/swift-evolution/blob/master/proposals/0211-unicode-scalar-properties.md>
7139+
[SE-0212]: <https://github.com/apple/swift-evolution/blob/master/proposals/0212-compiler-version-directive.md>
7140+
7141+
[SR-106]: <https://bugs.swift.org/browse/SR-106>
69727142
[SR-419]: <https://bugs.swift.org/browse/SR-419>
69737143
[SR-1009]: <https://bugs.swift.org/browse/SR-1009>
69747144
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>

0 commit comments

Comments
 (0)