Skip to content

Commit e04c26c

Browse files
---
yaml --- r: 348941 b: refs/heads/master c: eb02f20 h: refs/heads/master i: 348939: 8ef3a5d
1 parent f93858b commit e04c26c

File tree

2,626 files changed

+151606
-115867
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,626 files changed

+151606
-115867
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9b6ff03f9eff89ee93831080a27e47b16c784f99
2+
refs/heads/master: eb02f20f9950ab1f0149c4712ac50ae44bd0b25f
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.swift.gyb linguist-language=Swift
2+
*.cpp.gyb linguist-language=C++

trunk/CHANGELOG.md

Lines changed: 166 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,159 @@ CHANGELOG
44
<details>
55
<summary>Note: This is in reverse chronological order, so newer entries are added to the top.</summary>
66

7-
| Contents |
8-
| :--------------------- |
9-
| [Swift Next](#swift-next) |
10-
| [Swift 5.1](#swift-51) |
11-
| [Swift 5.0](#swift-50) |
12-
| [Swift 4.2](#swift-42) |
13-
| [Swift 4.1](#swift-41) |
14-
| [Swift 4.0](#swift-40) |
15-
| [Swift 3.1](#swift-31) |
16-
| [Swift 3.0](#swift-30) |
17-
| [Swift 2.2](#swift-22) |
18-
| [Swift 2.1](#swift-21) |
19-
| [Swift 2.0](#swift-20) |
20-
| [Swift 1.2](#swift-12) |
21-
| [Swift 1.1](#swift-11) |
22-
| [Swift 1.0](#swift-10) |
7+
| Version | Released | Toolchain |
8+
| :--------------------- | :--------- | :---------- |
9+
| [Swift 5.2](#swift-52) | | |
10+
| [Swift 5.1](#swift-51) | 2019-09-20 | Xcode 11.0 |
11+
| [Swift 5.0](#swift-50) | 2019-03-25 | Xcode 10.2 |
12+
| [Swift 4.2](#swift-42) | 2018-09-17 | Xcode 10.0 |
13+
| [Swift 4.1](#swift-41) | 2018-03-29 | Xcode 9.3 |
14+
| [Swift 4.0](#swift-40) | 2017-09-19 | Xcode 9.0 |
15+
| [Swift 3.1](#swift-31) | 2017-03-27 | Xcode 8.3 |
16+
| [Swift 3.0](#swift-30) | 2016-09-13 | Xcode 8.0 |
17+
| [Swift 2.2](#swift-22) | 2016-03-21 | Xcode 7.3 |
18+
| [Swift 2.1](#swift-21) | 2015-10-21 | Xcode 7.1 |
19+
| [Swift 2.0](#swift-20) | 2015-09-17 | Xcode 7.0 |
20+
| [Swift 1.2](#swift-12) | 2015-04-08 | Xcode 6.3 |
21+
| [Swift 1.1](#swift-11) | 2014-12-02 | Xcode 6.1.1 |
22+
| [Swift 1.0](#swift-10) | 2014-09-15 | Xcode 6.0 |
2323

2424
</details>
2525

26-
Swift Next
27-
----------
26+
Swift 5.2
27+
---------
2828

29-
* [SR-8974][]:
29+
* [SR-11429][]:
3030

31-
Duplicate tuple element labels are no longer allowed, because it leads
32-
to incorrect behavior. For example:
31+
The compiler will now correctly strip argument labels from function references
32+
used with the `as` operator in a function call. As a result, the `as` operator
33+
can now be used to disambiguate a call to a function with argument labels.
34+
35+
```swift
36+
func foo(x: Int) {}
37+
func foo(x: UInt) {}
38+
39+
(foo as (Int) -> Void)(5) // Calls foo(x: Int)
40+
(foo as (UInt) -> Void)(5) // Calls foo(x: UInt)
41+
```
42+
43+
Previously this was only possible for functions without argument labels.
44+
45+
This change also means that a generic type alias can no longer be used to
46+
preserve the argument labels of a function reference through the `as`
47+
operator. The following is now rejected:
48+
49+
```swift
50+
typealias Magic<T> = T
51+
func foo(x: Int) {}
52+
(foo as Magic)(x: 5) // error: Extraneous argument label 'x:' in call
53+
```
54+
55+
The function value must instead be called without argument labels:
56+
57+
```swift
58+
(foo as Magic)(5)
59+
```
60+
61+
* [SR-11298][]:
62+
63+
A class-constrained protocol extension, where the extended protocol does
64+
not impose a class constraint, will now infer the constraint implicitly.
3365

66+
```swift
67+
protocol Foo {}
68+
class Bar: Foo {
69+
var someProperty: Int = 0
70+
}
71+
72+
// Even though 'Foo' does not impose a class constraint, it is automatically
73+
// inferred due to the Self: Bar constraint.
74+
extension Foo where Self: Bar {
75+
var anotherProperty: Int {
76+
get { return someProperty }
77+
// As a result, the setter is now implicitly nonmutating, just like it would
78+
// be if 'Foo' had a class constraint.
79+
set { someProperty = newValue }
80+
}
81+
}
82+
```
83+
84+
As a result, this could lead to code that currently compiles today to throw an error.
85+
86+
```swift
87+
protocol Foo {
88+
var someProperty: Int { get set }
89+
}
90+
91+
class Bar: Foo {
92+
var someProperty = 0
93+
}
94+
95+
extension Foo where Self: Bar {
96+
var anotherProperty1: Int {
97+
get { return someProperty }
98+
// This will now error, because the protocol requirement
99+
// is implicitly mutating and the setter is implicitly
100+
// nonmutating.
101+
set { someProperty = newValue } // Error
102+
}
103+
}
34104
```
35-
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
36105

37-
enum Foo { case bar(x: Int, x: Int) }
38-
let f: Foo = .bar(x: 0, x: 1)
106+
**Workaround**: Define a new mutable variable inside the setter that has a reference to `self`:
107+
108+
```swift
109+
var anotherProperty1: Int {
110+
get { return someProperty }
111+
set {
112+
var mutableSelf = self
113+
mutableSelf.someProperty = newValue // Okay
114+
}
115+
}
39116
```
40117

41-
will now be diagnosed as an error.
118+
* [SE-0253][]:
42119

43-
Note: You can still use duplicate labels when declaring functions and
44-
subscripts, as long as the internal labels are different. For example:
120+
Values of types that declare `func callAsFunction` methods can be called
121+
like functions. The call syntax is shorthand for applying
122+
`func callAsFunction` methods.
45123

124+
```swift
125+
struct Adder {
126+
var base: Int
127+
func callAsFunction(_ x: Int) -> Int {
128+
return x + base
129+
}
130+
}
131+
var adder = Adder(base: 3)
132+
adder(10) // returns 13, same as `adder.callAsFunction(10)`
46133
```
47-
func foo(bar x: Int, bar y: Int) {}
48-
subscript(a x: Int, a y: Int) -> Int {}
134+
135+
* `func callAsFunction` argument labels are required at call sites.
136+
* Multiple `func callAsFunction` methods on a single type are supported.
137+
* `mutating func callAsFunction` is supported.
138+
* `func callAsFunction` works with `throws` and `rethrows`.
139+
* `func callAsFunction` works with trailing closures.
140+
141+
* [SR-4206][]:
142+
143+
A method override is no longer allowed to have a generic signature with
144+
requirements not imposed by the base method. For example:
145+
146+
```
147+
protocol P {}
148+
149+
class Base {
150+
func foo<T>(arg: T) {}
151+
}
152+
153+
class Derived: Base {
154+
override func foo<T: P>(arg: T) {}
155+
}
49156
```
50157

158+
will now be diagnosed as an error.
159+
51160
* [SR-6118][]:
52161

53162
Subscripts can now declare default arguments:
@@ -68,6 +177,30 @@ Swift Next
68177
Swift 5.1
69178
---------
70179

180+
### 2019-09-20 (Xcode 11.0)
181+
182+
* [SR-8974][]:
183+
184+
Duplicate tuple element labels are no longer allowed, because it leads
185+
to incorrect behavior. For example:
186+
187+
```
188+
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
189+
190+
enum Foo { case bar(x: Int, x: Int) }
191+
let f: Foo = .bar(x: 0, x: 1)
192+
```
193+
194+
will now be diagnosed as an error.
195+
196+
Note: You can still use duplicate argument labels when declaring functions and
197+
subscripts, as long as the internal parameter names are different. For example:
198+
199+
```
200+
func foo(bar x: Int, bar y: Int) {}
201+
subscript(a x: Int, a y: Int) -> Int {}
202+
```
203+
71204
* [SE-0244][]:
72205

73206
Functions can now hide their concrete return type by declaring what protocols
@@ -7692,6 +7825,7 @@ Swift 1.0
76927825
[SE-0244]: <https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md>
76937826
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
76947827
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
7828+
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
76957829
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
76967830

76977831
[SR-106]: <https://bugs.swift.org/browse/SR-106>
@@ -7708,6 +7842,7 @@ Swift 1.0
77087842
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
77097843
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
77107844
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
7845+
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
77117846
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
77127847
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
77137848
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
@@ -7721,3 +7856,5 @@ Swift 1.0
77217856
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
77227857
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
77237858
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
7859+
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
7860+
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

0 commit comments

Comments
 (0)