Skip to content

Commit 69085ae

Browse files
committed
Merge branch 'master' of https://github.com/apple/swift
2 parents 47b4c7e + 6ced259 commit 69085ae

File tree

552 files changed

+13035
-5426
lines changed

Some content is hidden

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

552 files changed

+13035
-5426
lines changed

.pep8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[flake8]
2-
filename = *.py,80+-check,backtrace-check,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,check-incremental,clang++,coverage-build-db,coverage-generate-data,coverage-touch-tests,gyb,ld,line-directive,mock-distcc,ns-html2rst,PathSanitizingFileCheck,recursive-lipo,rth,run-test,submit-benchmark-results,update-checkout,viewcfg
2+
filename = *.py,80+-check,backtrace-check,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,check-incremental,clang++,coverage-build-db,coverage-generate-data,coverage-touch-tests,gyb,ld,line-directive,mock-distcc,ns-html2rst,PathSanitizingFileCheck,recursive-lipo,rth,run-test,submit-benchmark-results,update-checkout,viewcfg,symbolicate-linux-fatal

CHANGELOG.md

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,15 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
198198

199199
* [SE-0025][]:
200200

201-
A declaration marked as `private` can now only be accessed within the lexical
202-
scope it is declared in (essentially the enclosing curly braces `{}`).
203-
A `private` declaration at the top level of a file can be accessed anywhere
204-
in that file, as in Swift 2. The access level formerly known as `private` is
205-
now called `fileprivate`.
201+
The access level formerly known as `private` is now called `fileprivate`. A Swift 3 declaration marked `private` can no longer be accessed outside its lexical scope (essentially its enclosing curly braces `{}`). A `private` declaration at the top level of a file can be accessed anywhere within the same file, as it could in Swift 2.
206202

207203
* [SE-0131][]:
208204

209-
The standard library provides a new type `AnyHashable` for use in heterogeneous
210-
hashed collections. Untyped `NSDictionary` and `NSSet` APIs from Objective-C
211-
now import as `[AnyHashable: Any]` and `Set<AnyHashable>`.
205+
The standard library introduces the `AnyHashable` type for use in hashed heterogeneous collections. Untyped `NSDictionary` and `NSSet` Objective-C APIs now import as `[AnyHashable: Any]` and `Set<AnyHashable>`.
212206

213207
* [SE-0102][]:
214208

215-
The `@noreturn` attribute on function declarations and function types has been
216-
removed, in favor of an empty `Never` type:
209+
Swift removes the `@noreturn` attribute on function declarations and replaces the attribute with an empty `Never` type:
217210

218211
```swift
219212
@noreturn func fatalError(msg: String) { ... } // old
@@ -225,15 +218,11 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
225218

226219
* [SE-0116][]:
227220

228-
Objective-C APIs using `id` now import into Swift as `Any` instead of as `AnyObject`.
229-
Similarly, APIs using untyped `NSArray` and `NSDictionary` import as `[Any]` and
230-
`[AnyHashable: Any]`, respectively.
221+
Swift now imports Objective-C `id` APIs as `Any`. In Swift 2, `id` imported as `AnyObject`. Swift also imports untyped `NSArray` and `NSDictionary` as `[Any]` and `[AnyHashable: Any]`, respectively.
231222

232223
* [SE-0072][]:
233224

234-
Bridging conversions are no longer implicit. The conversion from a Swift value type to
235-
its corresponding object can be forced with `as`, e.g. `string as NSString`. Any Swift
236-
value can also be converted to its boxed `id` representation with `as AnyObject`.
225+
Swift eliminates implicit bridging conversions. Use `as` to force the conversion from a Swift value type to its corresponding object. For example, use `string as NSString`. Use `as AnyObject` to convert a Swift value to its boxed `id` representation.
237226

238227
* Collection subtype conversions and dynamic casts now work with protocol types:
239228

@@ -246,40 +235,36 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
246235

247236
* [SR-2131](https://bugs.swift.org/browse/SR-2131):
248237

249-
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a
250-
prefix and suffix of all strings.
238+
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a prefix and suffix of all strings.
251239

252240
* [SE-0128][]:
253241

254-
Some UnicodeScalar initializers (ones that are non-failable) now return an Optional,
255-
i.e., in case a UnicodeScalar can not be constructed, nil is returned.
242+
Some non-failable UnicodeScalar initializers now return an Optional. When a UnicodeScalar cannot be constructed, these initializers return nil.
256243

257244
```swift
258245
// Old
259246
var string = ""
260-
let codepoint: UInt32 = 55357 // this is invalid
261-
let ucode = UnicodeScalar(codepoint) // Program crashes at this point.
247+
let codepoint: UInt32 = 55357 // Invalid
248+
let ucode = UnicodeScalar(codepoint) // Program crashes here.
262249
string.append(ucode)
263250
```
264251

265-
After marking the initializer as failable, users can write code like this
266-
and the program will execute fine even if the codepoint isn't valid.
252+
The updated initializers allow users to write code that safely works around invalid codepoints, like this example:
267253

268254
```swift
269255
// New
270256
var string = ""
271-
let codepoint: UInt32 = 55357 // this is invalid
257+
let codepoint: UInt32 = 55357 // Invalid
272258
if let ucode = UnicodeScalar(codepoint) {
273-
string.append(ucode)
259+
string.append(ucode)
274260
} else {
275-
// do something else
261+
// do something else
276262
}
277263
```
278264

279265
* [SE-0095][]:
280266

281-
The `protocol<...>` composition construct has been removed. In its
282-
place, an infix type operator `&` has been introduced.
267+
Swift removes the `protocol<...>` composition construct and introduces an infix type operator `&` in its place.
283268

284269
```swift
285270
let a: Foo & Bar
@@ -289,13 +274,11 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
289274
typealias G = GenericStruct<Foo & Bar>
290275
```
291276

292-
The empty protocol composition, the `Any` type, was previously
293-
defined as being `protocol<>`. This has been removed from the
294-
standard library and `Any` is now a keyword with the same behaviour.
277+
Swift previously defined the empty protocol composition (the `Any` type) as `protocol<>`. This definition has been removed from the standard library. The `Any` keyword behavior remains unchanged.
295278

296279
* [SE-0091][]:
297280

298-
Operators can now be defined within types or extensions thereof. For example:
281+
Swift permits you to define operators within types or their extensions. For example:
299282

300283
```swift
301284
struct Foo: Equatable {
@@ -307,18 +290,16 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
307290
}
308291
```
309292

310-
Such operators must be declared as `static` (or, within a class, `class
311-
final`), and have the same signature as their global counterparts. As part of
312-
this change, operator requirements declared in protocols must also be
313-
explicitly declared `static`:
293+
You must declare these operators as `static` (or, within a class, `class
294+
final`) and they must use the same signature as their global counterparts. As part of this change, protocol-declared operator requirements must be declared `static` explicitly:
314295

315296
```swift
316297
protocol Equatable {
317298
static func ==(lhs: Self, rhs: Self) -> Bool
318299
}
319300
```
320301

321-
Note that the type checker performance optimization described by [SE-0091][]
302+
Note: The type checker performance optimization described by [SE-0091][]
322303
is not yet implemented.
323304

324305
* [SE-0099][]:
@@ -3663,7 +3644,7 @@ Swift 1.0
36633644
accepts inouts or `nil`:
36643645

36653646
```swift
3666-
var error: NSError? = nil
3647+
var error: NSError?
36673648
let words = NSString.stringWithContentsOfFile("/usr/share/dict/words",
36683649
encoding: .UTF8StringEncoding,
36693650
error: &error)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
|**macOS** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-osx/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-osx)|[![Build Status](https://ci.swift.org/job/oss-swift-package-osx/badge/icon)](https://ci.swift.org/job/oss-swift-package-osx)|
77
|**Ubuntu 14.04** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04)|
88
|**Ubuntu 15.10** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-15_10/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-15_10)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-15_10/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-15_10)|
9+
|**Ubuntu 16.04** |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04)|
910

1011
**Welcome to Swift!**
1112

apinotes/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ set(SWIFT_API_NOTES_INPUTS
3535
ObjectiveC
3636
PassKit
3737
Photos
38-
QuartzCore
3938
QuickLook
4039
SafariServices
4140
SceneKit

apinotes/Metal.apinotes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Name: Metal
33
Tags:
44
- Name: MTLCommandBufferError
5-
SwiftName: MTLCommandBufferErrorDomain
5+
NSErrorDomain: MTLCommandBufferErrorDomain
66
- Name: MTLLibraryError
7-
SwiftName: MTLLibraryErrorDomain
7+
NSErrorDomain: MTLLibraryErrorDomain
88
- Name: MTLRenderPipelineError
9-
SwiftName: MTLRenderPipelineErrorDomain
9+
NSErrorDomain: MTLRenderPipelineErrorDomain
1010
Enumerators:
1111
- Name: MTLResourceStorageModeShared
1212
SwiftName: storageModeShared

apinotes/NetworkExtension.apinotes

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Name: NetworkExtension
33
Tags:
44
- Name: NEAppProxyFlowError
5-
SwiftName: NEAppProxyErrorDomain
5+
NSErrorDomain: NEAppProxyErrorDomain
66
- Name: NEFilterError
7-
SwiftName: NEFilterErrorDomain
7+
NSErrorDomain: NEFilterErrorDomain
88
- Name: NETunnelProviderError
9-
SwiftName: NETunnelProviderErrorDomain
9+
NSErrorDomain: NETunnelProviderErrorDomain
1010
- Name: NEVPNError
11-
SwiftName: NEVPNErrorDomain
11+
NSErrorDomain: NEVPNErrorDomain

apinotes/ObjectiveC.apinotes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Protocols:
101101
- Selector: class
102102
MethodKind: Instance
103103
Availability: nonswift
104-
AvailabilityMsg: use 'dynamicType' instead
104+
AvailabilityMsg: use 'type(of:)' instead
105105
- Selector: 'conformsToProtocol:'
106106
MethodKind: Instance
107107
Nullability:

apinotes/QuartzCore.apinotes

Lines changed: 0 additions & 5 deletions
This file was deleted.

apinotes/SafariServices.apinotes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Name: SafariServices
33
Tags:
44
- Name: SFErrorCode
5-
SwiftName: SFErrorDomain
5+
NSErrorDomain: SFErrorDomain
66
- Name: SSReadingListErrorCode
7-
SwiftName: SSReadingListErrorDomain
7+
NSErrorDomain: SSReadingListErrorDomain

benchmark/CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ set(SWIFT_BENCH_MODULES
3838
single-source/Chars
3939
single-source/ClassArrayGetter
4040
single-source/DeadArray
41+
single-source/DictTest
42+
single-source/DictTest2
43+
single-source/DictTest3
4144
single-source/DictionaryBridge
4245
single-source/DictionaryLiteral
4346
single-source/DictionaryRemove
4447
single-source/DictionarySwap
45-
single-source/DictTest
46-
single-source/DictTest2
47-
single-source/DictTest3
4848
single-source/ErrorHandling
4949
single-source/Fibonacci
5050
single-source/GlobalClass
@@ -59,10 +59,10 @@ set(SWIFT_BENCH_MODULES
5959
single-source/Memset
6060
single-source/MonteCarloE
6161
single-source/MonteCarloPi
62-
single-source/NopDeinit
6362
single-source/NSDictionaryCastToSwift
6463
single-source/NSError
6564
single-source/NSStringConversion
65+
single-source/NopDeinit
6666
single-source/ObjectAllocation
6767
single-source/OpenClose
6868
single-source/Phonebook
@@ -72,22 +72,22 @@ set(SWIFT_BENCH_MODULES
7272
single-source/Prims
7373
single-source/ProtocolDispatch
7474
single-source/ProtocolDispatch2
75-
single-source/RangeAssignment
7675
single-source/RC4
77-
single-source/RecursiveOwnedParameter
7876
single-source/RGBHistogram
77+
single-source/RangeAssignment
78+
single-source/RecursiveOwnedParameter
7979
single-source/SetTests
8080
single-source/SevenBoom
8181
single-source/Sim2DArray
8282
single-source/SortLettersInPlace
8383
single-source/SortStrings
8484
single-source/StaticArray
8585
single-source/StrComplexWalk
86+
single-source/StrToInt
8687
single-source/StringBuilder
8788
single-source/StringInterpolation
8889
single-source/StringTests
8990
single-source/StringWalk
90-
single-source/StrToInt
9191
single-source/SuperChars
9292
single-source/TwoSum
9393
single-source/TypeFlood
@@ -139,7 +139,8 @@ runcmd(COMMAND "xcrun" "-toolchain" "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" "-f" "clan
139139
# You have to delete CMakeCache.txt in the swift build to force a
140140
# reconfiguration.
141141
set(SWIFT_EXTRA_BENCH_CONFIGS CACHE STRING
142-
"A semicolon separated list of benchmark configurations. Available configurations: <Optlevel>_SINGLEFILE, <Optlevel>_MULTITHREADED")
142+
"A semicolon separated list of benchmark configurations. \
143+
Available configurations: <Optlevel>_SINGLEFILE, <Optlevel>_MULTITHREADED")
143144

144145
# Syntax for an optset: <optimization-level>_<configuration>
145146
# where "_<configuration>" is optional.
@@ -148,6 +149,11 @@ if(NOT SWIFT_OPTIMIZATION_LEVELS)
148149
${SWIFT_EXTRA_BENCH_CONFIGS})
149150
endif()
150151

152+
set(SWIFT_BENCHMARK_NUM_O_ITERATIONS "" CACHE STRING
153+
"Number of iterations to perform when running -O benchmarks via cmake")
154+
set(SWIFT_BENCHMARK_NUM_ONONE_ITERATIONS "" CACHE STRING
155+
"Number of iterations to perform when running -Onone benchmarks via cmake")
156+
151157
# Options for the default (= empty) configuration
152158
set(BENCHOPTS "-whole-module-optimization")
153159

0 commit comments

Comments
 (0)