Skip to content

Commit e144f79

Browse files
author
Greg Parker
committed
Merge branch 'master' of github.com:apple/swift into new-refcount-representation
2 parents af5f37d + e1fd8aa commit e144f79

File tree

8,507 files changed

+95521
-43605
lines changed

Some content is hidden

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

8,507 files changed

+95521
-43605
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,14 @@ docs/_build
4040
CMakeCache.txt
4141
CMakeFiles
4242
.atom-build.json
43+
44+
#==============================================================================#
45+
# Ignore compile database
46+
#==============================================================================#
47+
compile_commands.json
48+
49+
# Ignore generated GYB files until we fix the workaround on Windows
50+
#==============================================================================#
51+
8
52+
4
53+
SortedCFDatabase.def

CHANGELOG.md

Lines changed: 125 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,119 @@ CHANGELOG
1717

1818
</details>
1919

20+
* More types of C macros which define integer constants are supported by the
21+
importer. Specifically the `+, -, *, /, ^, >>, ==, <, <=, >, >=` operators
22+
are now recognized, and the previously-supported `<<, &&, ||, &, |`
23+
operators always look through importable macros on each side of the operator.
24+
Logical AND and OR macros (`&&` and `||`) are now imported as Boolean
25+
constants, rather than integers of value 0 or 1.
26+
27+
```c
28+
#define HIGHER (5 + 5)
29+
#define THE_EDGE (INT64_MAX - 1)
30+
#define FORTY_TWO (6 * 9)
31+
#define SPLIT (THE_EDGE / FORTY_TWO)
32+
33+
#define HALF_AND_HALF (UINT64_MAX ^ UINT32_MAX)
34+
35+
#define SMALL (BITWIDTH == 32)
36+
#define TINY (BITWIDTH <= 16)
37+
#define LIMITED (SMALL || TINY) // now imported as Bool.
38+
```
39+
40+
**Add new entries to the top of this file, not here!**
41+
2042
Swift 3.1
2143
---------
2244
45+
* [SE-0080][]:
46+
47+
Adds a new family of conversion initializers to all numeric types that
48+
either complete successfully without loss of information or return nil.
49+
50+
* Swift will now warn when an `NSObject` subclass attempts to override the
51+
class `initialize` method. Swift doesn't guarantee that references to class
52+
names trigger Objective-C class realization if they have no other
53+
side effects, leading to bugs when Swift code attempted to override
54+
`initialize`.
55+
56+
* [SR-2394](https://bugs.swift.org/browse/SR-2394)
57+
58+
C functions that "return twice" are no longer imported into Swift. Instead,
59+
they are explicitly made unavailable, so attempting to reference them will
60+
result in a compilation error.
61+
62+
Examples of functions that "return twice" include `vfork` and `setjmp`.
63+
These functions change the control flow of a program in ways that that Swift
64+
has never supported. For example, definitive initialization of variables,
65+
a core Swift language feature, could not be guaranteed when these functions
66+
were used.
67+
68+
Swift code that references these functions will no longer compile. Although
69+
this could be considered a source-breaking change, it's important to note that
70+
any use of these functions would have most likely crashed at runtime. Now,
71+
the compiler will prevent them from being used in the first place.
72+
73+
* Indirect fields from C structures and unions are now always imported, while
74+
they previously weren't imported if they belonged to a union. This is done by
75+
naming anonymous fields. For example:
76+
77+
```c
78+
typedef struct foo_t {
79+
union {
80+
int a;
81+
double b;
82+
};
83+
} foo_t;
84+
```
85+
86+
Get imported as:
87+
88+
```swift
89+
struct foo_t {
90+
struct __Unnamed_union___Anonymous_field0 {
91+
var a : Int { get set }
92+
var b : Double { get set }
93+
}
94+
var __Anonymous_field0 : foo_t.__Unnamed_union___Anonymous_field0
95+
96+
// a and b are computed properties accessing the content of __Anonymous_field0
97+
var a : Int { get set }
98+
var b : Double { get set }
99+
}
100+
```
101+
102+
Since new symbols are exposed from imported structure/unions, this may conflict
103+
with existing code that extended C types in order to provide their own accessors
104+
to the indirect fields.
105+
106+
* The `withoutActuallyEscaping` function from [SE-0103][] has been implemented.
107+
To pass off a non-escaping closure to an API that formally takes an
108+
`@escaping` closure, but which is used in a way that will not in fact
109+
escape it in practice, use `withoutActuallyEscaping` to get an escapable
110+
copy of the closure and delimit its expected lifetime. For example:
111+
112+
```swift
113+
func doSimultaneously(_ f: () -> (), and g: () -> (), on q: DispatchQueue) {
114+
// DispatchQueue.async normally has to be able to escape its closure
115+
// since it may be called at any point after the operation is queued.
116+
// By using a barrier, we ensure it does not in practice escape.
117+
withoutActuallyEscaping(f) { escapableF in
118+
withoutActuallyEscaping(g) { escapableG in
119+
q.async(escapableF)
120+
q.async(escapableG)
121+
q.sync(flags: .barrier) {}
122+
}
123+
}
124+
// `escapableF` and `escapableG` must be dequeued by the point
125+
// `withoutActuallyEscaping` returns.
126+
}
127+
```
128+
129+
The old workaround of using `unsafeBitCast` to cast to an `@escaping` type
130+
is not guaranteed to work in future versions of Swift, and will
131+
now raise a warning.
132+
23133
* [SR-1446](https://bugs.swift.org/browse/SR-1446)
24134

25135
Nested types may now appear inside generic types, and nested types may have their own generic parameters:
@@ -56,8 +166,6 @@ Swift 3.1
56166
subsequence after dropping the longest subsequence satisfying a
57167
predicate.
58168

59-
**Add new entries to the top of this file, not here!**
60-
61169
Swift 3.0
62170
---------
63171

@@ -300,8 +408,8 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
300408
```swift
301409
let a: Foo & Bar
302410
let b = value as? A & B & C
303-
func foo<T : Foo & Bar>(x: T) { }
304-
func bar(x: Foo & Bar) { }
411+
func foo<T : Foo & Bar>(x: T) { ... }
412+
func bar(x: Foo & Bar) { ... }
305413
typealias G = GenericStruct<Foo & Bar>
306414
```
307415

@@ -1079,7 +1187,7 @@ Swift 2.0
10791187
* Public extensions of generic types are now permitted.
10801188

10811189
```swift
1082-
public extension Array { }
1190+
public extension Array { ... }
10831191
```
10841192

10851193
**(16974298)**
@@ -1239,8 +1347,8 @@ Swift 2.0
12391347
For example:
12401348

12411349
```swift
1242-
func produceGizmoUsingTechnology() throws -> Gizmo { }
1243-
func produceGizmoUsingMagic() throws -> Gizmo { }
1350+
func produceGizmoUsingTechnology() throws -> Gizmo { ... }
1351+
func produceGizmoUsingMagic() throws -> Gizmo { ... }
12441352

12451353
if let result = try? produceGizmoUsingTechnology() { return result }
12461354
if let result = try? produceGizmoUsingMagic() { return result }
@@ -1413,7 +1521,7 @@ Swift 2.0
14131521
function or initializer. For example:
14141522

14151523
```swift
1416-
func doSomethingToValues(values: Int... , options: MyOptions = [], fn: (Int) -&gt; Void) { }
1524+
func doSomethingToValues(values: Int... , options: MyOptions = [], fn: (Int) -&gt; Void) { ... }
14171525
```
14181526

14191527
**(20127197)**
@@ -1445,7 +1553,7 @@ Swift 2.0
14451553
**(17227475)**
14461554

14471555
* When delegating or chaining to a failable initializer (for example, with
1448-
`self.init()` or `super.init()`), one can now force-unwrap the result with
1556+
`self.init(...)` or `super.init(...)`), one can now force-unwrap the result with
14491557
`!`. For example:
14501558

14511559
```swift
@@ -2152,7 +2260,7 @@ Swift 1.2
21522260
}
21532261

21542262
class MySomethingDelegate : SomethingDelegate {
2155-
@objc func didSomething() { }
2263+
@objc func didSomething() { ... }
21562264
}
21572265
```
21582266

@@ -6293,3 +6401,10 @@ Swift 1.0
62936401
[SE-0138]: <https://github.com/apple/swift-evolution/blob/master/proposals/0138-unsaferawbufferpointer.md>
62946402
[SE-0139]: <https://github.com/apple/swift-evolution/blob/master/proposals/0139-bridge-nsnumber-and-nsvalue.md>
62956403
[SE-0140]: <https://github.com/apple/swift-evolution/blob/master/proposals/0140-bridge-optional-to-nsnull.md>
6404+
[SE-0141]: <https://github.com/apple/swift-evolution/blob/master/proposals/0141-available-by-swift-version.md>
6405+
[SE-0142]: <https://github.com/apple/swift-evolution/blob/master/proposals/0142-associated-types-constraints.md>
6406+
[SE-0143]: <https://github.com/apple/swift-evolution/blob/master/proposals/0143-conditional-conformances.md>
6407+
[SE-0144]: <https://github.com/apple/swift-evolution/blob/master/proposals/0144-allow-single-dollar-sign-as-valid-identifier.md>
6408+
[SE-0145]: <https://github.com/apple/swift-evolution/blob/master/proposals/0145-package-manager-version-pinning.md>
6409+
[SE-0146]: <https://github.com/apple/swift-evolution/blob/master/proposals/0146-package-manager-product-definitions.md>
6410+
[SE-0147]: <https://github.com/apple/swift-evolution/blob/master/proposals/0147-move-unsafe-initialize-from.md>

0 commit comments

Comments
 (0)