Skip to content

Commit 32f7d4e

Browse files
authored
---
yaml --- r: 341993 b: refs/heads/rxwei-patch-1 c: b89764a h: refs/heads/master i: 341991: a386ffb
1 parent 67144d3 commit 32f7d4e

File tree

247 files changed

+3544
-2457
lines changed

Some content is hidden

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

247 files changed

+3544
-2457
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: b981afb29b26dc02966a75aaa09ed4fd9afca8c4
1018+
refs/heads/rxwei-patch-1: b89764a05f014abdf98726e510c6f9a35f01b0f6
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/CHANGELOG.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,24 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

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

31-
Duplicate tuple element labels are no longer allowed, because it leads
32-
to incorrect behavior. For example:
31+
A method override is no longer allowed to have a generic signature with
32+
requirements not imposed by the base method. For example:
3333

3434
```
35-
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
36-
37-
enum Foo { case bar(x: Int, x: Int) }
38-
let f: Foo = .bar(x: 0, x: 1)
35+
protocol P {}
36+
37+
class Base {
38+
func foo<T>(arg: T) {}
39+
}
40+
41+
class Derived: Base {
42+
override func foo<T: P>(arg: T) {}
43+
}
3944
```
4045

41-
will now be diagnosed as an error.
42-
43-
Note: You can still use duplicate labels when declaring functions and
44-
subscripts, as long as the internal labels are different. For example:
45-
46-
```
47-
func foo(bar x: Int, bar y: Int) {}
48-
subscript(a x: Int, a y: Int) -> Int {}
49-
```
46+
will now be diagnosed as an error.
5047

5148
* [SR-6118][]:
5249

@@ -68,6 +65,28 @@ Swift Next
6865
Swift 5.1
6966
---------
7067

68+
* [SR-8974][]:
69+
70+
Duplicate tuple element labels are no longer allowed, because it leads
71+
to incorrect behavior. For example:
72+
73+
```
74+
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
75+
76+
enum Foo { case bar(x: Int, x: Int) }
77+
let f: Foo = .bar(x: 0, x: 1)
78+
```
79+
80+
will now be diagnosed as an error.
81+
82+
Note: You can still use duplicate argument labels when declaring functions and
83+
subscripts, as long as the internal parameter names are different. For example:
84+
85+
```
86+
func foo(bar x: Int, bar y: Int) {}
87+
subscript(a x: Int, a y: Int) -> Int {}
88+
```
89+
7190
* [SE-0244][]:
7291

7392
Functions can now hide their concrete return type by declaring what protocols
@@ -7708,6 +7727,7 @@ Swift 1.0
77087727
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
77097728
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
77107729
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
7730+
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
77117731
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
77127732
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
77137733
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>

branches/rxwei-patch-1/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
7676

7777
#### macOS
7878

79-
To build for macOS, you need [Xcode 11 beta](https://developer.apple.com/xcode/downloads/).
79+
To build for macOS, you need [Xcode 11 beta 4](https://developer.apple.com/xcode/downloads/).
8080
The required version of Xcode changes frequently, and is often a beta release.
8181
Check this document or the host information on <https://ci.swift.org> for the
8282
current required version.

branches/rxwei-patch-1/benchmark/Package.swift

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22

33
import PackageDescription
44
import Foundation
@@ -9,10 +9,15 @@ unsupportedTests.insert("ObjectiveCBridging")
99
unsupportedTests.insert("ObjectiveCBridgingStubs")
1010
#endif
1111

12-
// This is a stop gap hack so we can edit benchmarks in Xcode.
13-
let singleSourceLibraries: [String] = {
12+
//===---
13+
// Single Source Libraries
14+
//
15+
16+
/// Return the source files in subDirectory that we will translate into
17+
/// libraries. Each source library will be compiled as its own module.
18+
func getSingleSourceLibraries(subDirectory: String) -> [String] {
1419
let f = FileManager.`default`
15-
let dirURL = URL(fileURLWithPath: "single-source").absoluteURL
20+
let dirURL = URL(fileURLWithPath: subDirectory)
1621
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
1722
includingPropertiesForKeys: nil)
1823
return fileURLs.compactMap { (path: URL) -> String? in
@@ -25,27 +30,45 @@ let singleSourceLibraries: [String] = {
2530
return nil
2631
}
2732

28-
let s = String(c[0])
33+
let name = String(c[0])
2934

3035
// We do not support this test.
31-
if unsupportedTests.contains(s) {
36+
if unsupportedTests.contains(name) {
3237
return nil
3338
}
3439

35-
assert(s != "PrimsSplit")
36-
return s
40+
return name
3741
}
38-
}()
42+
}
43+
44+
var singleSourceLibraryDirs: [String] = []
45+
singleSourceLibraryDirs.append("single-source")
46+
47+
var singleSourceLibraries: [String] = singleSourceLibraryDirs.flatMap {
48+
getSingleSourceLibraries(subDirectory: $0)
49+
}
3950

40-
let multiSourceLibraries: [String] = {
51+
//===---
52+
// Multi Source Libraries
53+
//
54+
55+
func getMultiSourceLibraries(subDirectory: String) -> [(String, String)] {
4156
let f = FileManager.`default`
42-
let dirURL = URL(fileURLWithPath: "multi-source").absoluteURL
43-
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
44-
includingPropertiesForKeys: nil)
45-
return fileURLs.map { (path: URL) -> String in
46-
return path.lastPathComponent
47-
}
48-
}()
57+
let dirURL = URL(string: subDirectory)!
58+
let subDirs = try! f.contentsOfDirectory(at: dirURL, includingPropertiesForKeys: nil)
59+
return subDirs.map { (subDirectory, $0.lastPathComponent) }
60+
}
61+
62+
var multiSourceLibraryDirs: [String] = []
63+
multiSourceLibraryDirs.append("multi-source")
64+
65+
var multiSourceLibraries: [(parentSubDir: String, name: String)] = multiSourceLibraryDirs.flatMap {
66+
getMultiSourceLibraries(subDirectory: $0)
67+
}
68+
69+
//===---
70+
// Products
71+
//
4972

5073
var products: [Product] = []
5174
products.append(.library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]))
@@ -54,9 +77,15 @@ products.append(.library(name: "DriverUtils", type: .static, targets: ["DriverUt
5477
products.append(.library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]))
5578
#endif
5679
products.append(.executable(name: "SwiftBench", targets: ["SwiftBench"]))
57-
products.append(.library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"]))
80+
5881
products += singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
59-
products += multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
82+
products += multiSourceLibraries.map {
83+
return .library(name: $0.name, type: .static, targets: [$0.name])
84+
}
85+
86+
//===---
87+
// Targets
88+
//
6089

6190
var targets: [Target] = []
6291
targets.append(.target(name: "TestsUtils", path: "utils", sources: ["TestsUtils.swift"]))
@@ -73,7 +102,7 @@ swiftBenchDeps.append(.target(name: "ObjectiveCTests"))
73102
#endif
74103
swiftBenchDeps.append(.target(name: "DriverUtils"))
75104
swiftBenchDeps += singleSourceLibraries.map { .target(name: $0) }
76-
swiftBenchDeps += multiSourceLibraries.map { .target(name: $0) }
105+
swiftBenchDeps += multiSourceLibraries.map { .target(name: $0.name) }
77106

78107
targets.append(
79108
.target(name: "SwiftBench",
@@ -92,20 +121,27 @@ var singleSourceDeps: [Target.Dependency] = [.target(name: "TestsUtils")]
92121
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
93122
singleSourceDeps.append(.target(name: "ObjectiveCTests"))
94123
#endif
95-
targets += singleSourceLibraries.map { x in
96-
return .target(name: x,
124+
125+
targets += singleSourceLibraries.map { name in
126+
return .target(name: name,
97127
dependencies: singleSourceDeps,
98128
path: "single-source",
99-
sources: ["\(x).swift"])
129+
sources: ["\(name).swift"])
100130
}
101-
targets += multiSourceLibraries.map { x in
102-
return .target(name: x,
131+
132+
targets += multiSourceLibraries.map { lib in
133+
return .target(
134+
name: lib.name,
103135
dependencies: [
104136
.target(name: "TestsUtils")
105137
],
106-
path: "multi-source/\(x)")
138+
path: lib.parentSubDir)
107139
}
108140

141+
//===---
142+
// Top Level Definition
143+
//
144+
109145
let p = Package(
110146
name: "swiftbench",
111147
products: products,

branches/rxwei-patch-1/benchmark/README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
Swift Benchmark Suite
2-
=====================
1+
# Swift Benchmark Suite
32

43
This directory contains the Swift Benchmark Suite.
54

6-
Running Swift Benchmarks
7-
------------------------
5+
## Running Swift Benchmarks
86

97
To run Swift benchmarks, pass the `--benchmark` flag to `build-script`. The
108
current benchmark results will be compared to the previous run's results if
@@ -16,8 +14,7 @@ impacting changes, and run the benchmarks again. Upon benchmark completion, the
1614
benchmark results for the development branch will be compared to the most
1715
recent benchmark results for `master`.
1816

19-
Building with build-script
20-
--------------------------
17+
## Building with build-script
2118

2219
By default, Swift benchmarks for OS X are compiled during the Swift build
2320
process. To build Swift benchmarks for additional platforms, pass the following
@@ -33,8 +30,7 @@ drivers dynamically link Swift standard library dylibs from a path
3330
relative to their run-time location (../lib/swift) so the standard
3431
library should be distributed alongside them.
3532

36-
Building Independently
37-
----------------------
33+
## Building Independently
3834

3935
To build the Swift benchmarks using only an Xcode installation: install an
4036
Xcode version with Swift support, install cmake 2.8.12, and ensure Xcode is
@@ -110,8 +106,7 @@ installed libraries instead, enable
110106
This will reflect the performance of the Swift standard library
111107
installed on the device, not the one included in the Swift root.
112108

113-
Using the Benchmark Driver
114-
--------------------------
109+
## Using the Benchmark Driver
115110

116111
### Usage
117112

@@ -154,17 +149,15 @@ You can use test numbers instead of test names like this:
154149
Test numbers are not stable in the long run, adding and removing tests from the
155150
benchmark suite will reorder them, but they are stable for a given build.
156151

157-
Using the Harness Generator
158-
---------------------------
152+
## Using the Harness Generator
159153

160154
`scripts/generate_harness/generate_harness.py` runs `gyb` to automate generation
161155
of some benchmarks.
162156

163157
** FIXME ** `gyb` should be invoked automatically during the
164158
build so that manually invoking `generate_harness.py` is not required.
165159

166-
Adding New Benchmarks
167-
---------------------
160+
## Adding New Benchmarks
168161

169162
The harness generator supports both single and multiple file tests.
170163

@@ -244,8 +237,8 @@ public func run_YourTestName(N: Int) {
244237
The current set of tags are defined by the `BenchmarkCategory` enum in
245238
`TestsUtils.swift` .
246239

247-
Testing the Benchmark Drivers
248-
-----------------------------
240+
## Testing the Benchmark Drivers
241+
249242
When working on tests, after the initial build
250243
````
251244
swift-source$ ./swift/utils/build-script -R -B

branches/rxwei-patch-1/cmake/modules/AddSwift.cmake

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,10 +1512,9 @@ function(add_swift_host_library name)
15121512

15131513
if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
15141514
swift_install_in_component(TARGETS ${name}
1515-
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
1516-
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
1517-
RUNTIME DESTINATION bin
1518-
COMPONENT dev)
1515+
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT dev
1516+
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT dev
1517+
RUNTIME DESTINATION bin COMPONENT dev)
15191518
endif()
15201519

15211520
swift_is_installing_component(dev is_installing)
@@ -2139,10 +2138,15 @@ function(add_swift_target_library name)
21392138

21402139
if(sdk STREQUAL WINDOWS AND CMAKE_SYSTEM_NAME STREQUAL Windows)
21412140
swift_install_in_component(TARGETS ${name}-windows-${SWIFT_PRIMARY_VARIANT_ARCH}
2142-
RUNTIME DESTINATION "bin"
2143-
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}"
2144-
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}"
2145-
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
2141+
RUNTIME
2142+
DESTINATION "bin"
2143+
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
2144+
LIBRARY
2145+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}"
2146+
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
2147+
ARCHIVE
2148+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${SWIFT_PRIMARY_VARIANT_ARCH}"
2149+
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
21462150
PERMISSIONS ${file_permissions})
21472151
else()
21482152
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
@@ -2423,8 +2427,9 @@ function(add_swift_host_tool executable)
24232427
${ASHT_UNPARSED_ARGUMENTS})
24242428

24252429
swift_install_in_component(TARGETS ${executable}
2426-
RUNTIME DESTINATION bin
2427-
COMPONENT ${ASHT_SWIFT_COMPONENT})
2430+
RUNTIME
2431+
DESTINATION bin
2432+
COMPONENT ${ASHT_SWIFT_COMPONENT})
24282433

24292434
swift_is_installing_component(${ASHT_SWIFT_COMPONENT} is_installing)
24302435

branches/rxwei-patch-1/docs/StandardLibraryProgrammersManual.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ TODO: Should this subsume or link to [AccessControlInStdlib.rst](https://github.
5050

5151
Optionals can be unwrapped with `!`, which triggers a trap on nil. Alternatively, they can be `.unsafelyUnwrapped()`, which will check and trap in debug builds of user code. Internal to the standard library is `._unsafelyUnwrappedUnchecked()` which will only check and trap in debug builds of the standard library itself. These correspond directly with `_precondition`, `_debugPrecondition`, and `_sanityCheck`. See [that section](#precondition) for details.
5252

53+
#### UnsafeBitCast and Casting References
54+
55+
In general `unsafeBitCast` should be avoided because it's correctness relies on subtle assumptions that will never be enforced, and it indicates a bug in Swift's type system that should be fixed. It's less bad for non-pointer trivial types. Pointer casting should go through one of the memory binding API instead as a last resort.
56+
57+
Reference casting is more interesting. References casting can include converting to an Optional reference and converting from a class constrained existential.
58+
59+
The regular `as` operator should be able to convert between reference types with full dynamic checking.
60+
61+
`unsafeDownCast` is just as capable, but is only dynamically checked in debug mode or if the cast requires runtime support.
62+
63+
`_unsafeUncheckedDowncast` is the same but is only dynamically checked in the stdlib asserts build, or if the cast requires runtime support.
64+
65+
`_unsafeReferenceCast` is only dynamically checked if the cast requires runtime support. Additionally, it does not impose any static `AnyObject` constraint on the incoming reference. This is useful in a generic context where the object-ness can be determined dynamically, as done in some bridged containers.
5366

5467
### Builtins
5568

0 commit comments

Comments
 (0)