Skip to content

Commit a3fbb5f

Browse files
authored
Merge pull request #11 from apple/master
merge
2 parents 90b06be + 24abeca commit a3fbb5f

File tree

2,356 files changed

+84215
-37812
lines changed

Some content is hidden

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

2,356 files changed

+84215
-37812
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: 163 additions & 10 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,147 @@ Swift 5.0
6157
Swift 4.2
6258
---------
6359

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

104241
* [SE-0143][]
105242

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.
243+
Runtime query of conditional conformances is now implemented. Therefore,
244+
a dynamic cast such as `value as? P`, where the dynamic type of `value`
245+
conditionally conforms to `P`, will succeed when the conditional
246+
requirements are met.
110247

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

113250
Swift 4.1
114251
---------
115252

253+
### 2018-03-29 (Xcode 9.3)
254+
116255
* [SE-0075][]
117256

118257
Compile-time testing for the existence and importability of modules is now
@@ -6968,7 +7107,21 @@ Swift 1.0
69687107
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
69697108
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
69707109
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>
6971-
7110+
[SE-0200]: <https://github.com/apple/swift-evolution/blob/master/proposals/0200-raw-string-escaping.md>
7111+
[SE-0201]: <https://github.com/apple/swift-evolution/blob/master/proposals/0201-package-manager-local-dependencies.md>
7112+
[SE-0202]: <https://github.com/apple/swift-evolution/blob/master/proposals/0202-random-unification.md>
7113+
[SE-0203]: <https://github.com/apple/swift-evolution/blob/master/proposals/0203-rename-sequence-elements-equal.md>
7114+
[SE-0204]: <https://github.com/apple/swift-evolution/blob/master/proposals/0204-add-last-methods.md>
7115+
[SE-0205]: <https://github.com/apple/swift-evolution/blob/master/proposals/0205-withUnsafePointer-for-lets.md>
7116+
[SE-0206]: <https://github.com/apple/swift-evolution/blob/master/proposals/0206-hashable-enhancements.md>
7117+
[SE-0207]: <https://github.com/apple/swift-evolution/blob/master/proposals/0207-containsOnly.md>
7118+
[SE-0208]: <https://github.com/apple/swift-evolution/blob/master/proposals/0208-package-manager-system-library-targets.md>
7119+
[SE-0209]: <https://github.com/apple/swift-evolution/blob/master/proposals/0209-package-manager-swift-lang-version-update.md>
7120+
[SE-0210]: <https://github.com/apple/swift-evolution/blob/master/proposals/0210-key-path-offset.md>
7121+
[SE-0211]: <https://github.com/apple/swift-evolution/blob/master/proposals/0211-unicode-scalar-properties.md>
7122+
[SE-0212]: <https://github.com/apple/swift-evolution/blob/master/proposals/0212-compiler-version-directive.md>
7123+
7124+
[SR-106]: <https://bugs.swift.org/browse/SR-106>
69727125
[SR-419]: <https://bugs.swift.org/browse/SR-419>
69737126
[SR-1009]: <https://bugs.swift.org/browse/SR-1009>
69747127
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>

0 commit comments

Comments
 (0)