Skip to content

Commit ef98f2b

Browse files
committed
Merge branch 'master' into ver-4-bump
2 parents 157133d + 0ad6f73 commit ef98f2b

File tree

264 files changed

+7308
-1967
lines changed

Some content is hidden

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

264 files changed

+7308
-1967
lines changed

CHANGELOG.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,111 @@ CHANGELOG
2121
Swift 4.0
2222
---------
2323

24+
* [SE-0156][]
25+
26+
Protocol composition types can now contain one or more class type terms,
27+
forming a class-constrained protocol composition.
28+
29+
For example:
30+
31+
```swift
32+
protocol Paintable {
33+
func paint()
34+
}
35+
36+
class Canvas {
37+
var origin: CGPoint
38+
}
39+
40+
class Wall : Canvas, Paintable {
41+
func paint() { ... }
42+
}```
43+
44+
func render(_: Canvas & Paintable) { ... }
45+
46+
render(Wall())
47+
```
48+
49+
Note that class-constrained protocol compositions can be written and
50+
used in both Swift 3 and Swift 4 mode.
51+
52+
Generated headers for Swift APIs will map class-constrained protocol
53+
compositions to Objective-C protocol-qualified class types in both
54+
Swift 3 and Swift 4 mode (for instance, `NSSomeClass & SomeProto &
55+
OtherProto` in Swift becomes `NSSomeClass <SomeProto, OtherProto>`
56+
in Objective-C).
57+
58+
Objective-C APIs which use protocol-qualified class types differ in
59+
behavior when imported by a module compiled in Swift 3 mode and
60+
Swift 4 mode. In Swift 3 mode, these APIs will continue to import as
61+
protocol compositions without a class constraint
62+
(eg, `SomeProto & OtherProto`).
63+
64+
In Swift 4 mode, protocol-qualified class types import as
65+
class-constrained protocol compositions, for a more faithful mapping
66+
of APIs from Objective-C to Swift.
67+
68+
Note that the current implementation of class-constrained protocol
69+
compositions lacks three features outlined in the Swift evolution proposal:
70+
71+
- In the evolution proposal, a class-constrained is permitted to contain
72+
two different classes as long as one is a superclass of the other.
73+
The current implementation only allows multiple classes to appear in
74+
the composition if they are identical.
75+
76+
- In the evolution proposal, associated type and class inheritance clauses
77+
are generalized to allow class-constrained protocol compositions. The
78+
current implementation does not allow this.
79+
80+
- In the evolution proposal, protocol inheritance clauses are allowed to
81+
contain a class, placing a requirement that all conforming types are
82+
a subclass of the given class. The current implementation does not
83+
allow this.
84+
85+
These missing aspects of the proposal can be introduced in a future
86+
release without breaking source compatibility with existing code.
87+
88+
* [SE-0142][]
89+
90+
Protocols and associated types can now contain `where` clauses that
91+
provide additional restrictions on associated types. For example:
92+
93+
```swift
94+
protocol StringRepresentable: RawRepresentable
95+
where RawValue == String { }
96+
97+
protocol RawStringWrapper {
98+
associatedtype Wrapped: RawRepresentable
99+
where Wrapper.RawValue == String
100+
}
101+
```
102+
103+
* [SE-0160][]
104+
105+
In Swift 4 mode, a declaration is inferred to be `@objc` where it is required for semantic consistency of the programming model. Specifically, it is inferred when:
106+
107+
* The declaration is an override of an `@objc` declaration
108+
* The declaration satisfies a requirement in an `@objc` protocol
109+
* The declaration has one of the following attributes: `@IBAction`, `@IBOutlet`, `@IBInspectable`, `@GKInspectable`, or `@NSManaged`
110+
111+
Additionally, in Swift 4 mode, `dynamic` declarations that don't
112+
have `@objc` inferred based on the rules above will need to be
113+
explicitly marked `@objc`.
114+
115+
Swift 3 compatibility mode retains the more-permissive Swift 3
116+
rules for inference of `@objc` within subclasses of
117+
`NSObject`. However, the compiler will emit warnings about places
118+
where the Objective-C entry points for these inference cases are
119+
used, e.g., in a `#selector` or `#keyPath` expression, via
120+
messaging through `AnyObject`, or direct uses in Objective-C code
121+
within a mixed project. The warnings can be silenced by adding an
122+
explicit `@objc`. Uses of these entrypoints that are not
123+
statically visible to the compiler can be diagnosed at runtime by
124+
setting the environment variable
125+
`SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT` to a value between 1 and 3
126+
and testing the application. See the [migration discussion in
127+
SE-0160](https://github.com/apple/swift-evolution/blob/master/proposals/0160-objc-inference.md#minimal-migration-workflow).
128+
24129
* [SE-0138](https://github.com/apple/swift-evolution/blob/master/proposals/0138-unsaferawbufferpointer.md#amendment-to-normalize-the-slice-type):
25130

26131
Slicing a raw buffer no longer results in the same raw buffer

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ endif()
381381
option(SWIFT_BUILD_SOURCEKIT
382382
"Build SourceKit"
383383
${SWIFT_BUILD_SOURCEKIT_default})
384+
option(SWIFT_ENABLE_SOURCEKIT_TESTS
385+
"Enable running SourceKit tests"
386+
${SWIFT_BUILD_SOURCEKIT_default})
384387

385388
#
386389
# Assume a new enough ar to generate the index at construction time. This avoids

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ set(SWIFT_BENCH_MODULES
9494
single-source/SetTests
9595
single-source/SevenBoom
9696
single-source/Sim2DArray
97+
single-source/SortLargeExistentials
9798
single-source/SortLettersInPlace
9899
single-source/SortStrings
99100
single-source/StackPromo

benchmark/scripts/Benchmark_Driver

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ def get_current_git_branch(git_repo_path):
135135
'--abbrev-ref', 'HEAD'], stderr=subprocess.STDOUT).strip()
136136

137137

138+
def get_git_head_ID(git_repo_path):
139+
"""Return the short identifier for the HEAD commit of the repo
140+
`git_repo_path`"""
141+
return subprocess.check_output(
142+
['git', '-C', git_repo_path, 'rev-parse',
143+
'--short', 'HEAD'], stderr=subprocess.STDOUT).strip()
144+
145+
138146
def log_results(log_directory, driver, formatted_output, swift_repo=None):
139147
"""Log `formatted_output` to a branch specific directory in
140148
`log_directory`
@@ -143,6 +151,10 @@ def log_results(log_directory, driver, formatted_output, swift_repo=None):
143151
branch = get_current_git_branch(swift_repo)
144152
except (OSError, subprocess.CalledProcessError):
145153
branch = None
154+
try:
155+
head_ID = '-' + get_git_head_ID(swift_repo)
156+
except (OSError, subprocess.CalledProcessError):
157+
head_ID = ''
146158
timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime())
147159
if branch:
148160
output_directory = os.path.join(log_directory, branch)
@@ -154,7 +166,7 @@ def log_results(log_directory, driver, formatted_output, swift_repo=None):
154166
except OSError:
155167
pass
156168
log_file = os.path.join(output_directory,
157-
driver_name + '-' + timestamp + '.log')
169+
driver_name + '-' + timestamp + head_ID + '.log')
158170
print('Logging results to: %s' % log_file)
159171
with open(log_file, 'w') as f:
160172
f.write(formatted_output)

0 commit comments

Comments
 (0)