Skip to content

Commit d851abe

Browse files
author
Joe Shajrawi
authored
Merge branch 'master' into outline_copyddr
2 parents f4db364 + 79e9fd7 commit d851abe

File tree

317 files changed

+4969
-2195
lines changed

Some content is hidden

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

317 files changed

+4969
-2195
lines changed

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,54 @@ CHANGELOG
2222
Swift 4.1
2323
---------
2424

25+
* [SE-0157][] is implemented. Associated types can now declare "recursive"
26+
constraints, which require that the associated type conform to the enclosing
27+
protocol. The standard library protocols have been updated to make use of
28+
recursive constraints. For example, the `SubSequence` associated type of
29+
follows the enclosing protocol:
30+
31+
protocol Sequence {
32+
associatedtype Element
33+
associatedtype SubSequence: Sequence
34+
where SubSequence.Element == Element,
35+
SubSequence.SubSequence == SubSequence
36+
// ...
37+
}
38+
39+
protocol Collection: Sequence where Self.SubSequence: Collection {
40+
// ...
41+
}
42+
43+
As a result, a number of new constraints have been introduced into the
44+
standard library protocols:
45+
46+
* Make the `Indices` associated type have the same traversal requirements as
47+
its enclosing protocol, e.g., `Collection.Indices` conforms to
48+
`Collection`, `BidirectionalCollection.Indices` conforms to
49+
`BidirectionalCollection`, and so on
50+
* Make `Numeric.Magnitude` conform to `Numeric`
51+
* Use more efficient `SubSequence` types for lazy filter and map
52+
* Eliminate the `*Indexable` protocols
53+
54+
55+
* [SE-0161][] is fully implemented. KeyPaths now support subscript, optional
56+
chaining, and optional force-unwrapping components.
57+
58+
* [SE-0186][]
59+
60+
It is no longer valid to use the ownership keywords `weak` and `unowned` for property declarations in protocols. These keywords are meaningless and misleading when used in a protocol as they don't have any effect.
61+
62+
In Swift 3 and 4 mode the following example will produce a warning with a fix-it to remove the keyword. In Swift 5 mode and above an error will be produced.
63+
64+
```swift
65+
class A {}
66+
67+
protocol P {
68+
weak var weakVar: A? { get set }
69+
unowned var unownedVar: A { get set }
70+
}
71+
```
72+
2573
* [SE-0185][]
2674

2775
Structs and enums that declare a conformance to `Equatable`/`Hashable` now get an automatically synthesized implementation of `==`/`hashValue`. For structs, all stored properties must be `Equatable`/`Hashable`. For enums, all enum cases with associated values must be `Equatable`/`Hashable`.
@@ -6754,3 +6802,4 @@ Swift 1.0
67546802
[SE-0183]: <https://github.com/apple/swift-evolution/blob/master/proposals/0183-substring-affordances.md>
67556803
[SE-0184]: <https://github.com/apple/swift-evolution/blob/master/proposals/0184-unsafe-pointers-add-missing.md>
67566804
[SE-0185]: <https://github.com/apple/swift-evolution/blob/master/proposals/0185-synthesize-equatable-hashable.md>
6805+
[SE-0186]: <https://github.com/apple/swift-evolution/blob/master/proposals/0186-remove-ownership-keyword-support-in-protocols.md>

benchmark/utils/DriverUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ func internalMedian(_ inputs: [UInt64]) -> UInt64 {
312312

313313
#if SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
314314

315-
@_silgen_name("swift_leaks_startTrackingObjects")
315+
@_silgen_name("_swift_leaks_startTrackingObjects")
316316
func startTrackingObjects(_: UnsafeMutableRawPointer) -> ()
317-
@_silgen_name("swift_leaks_stopTrackingObjects")
317+
@_silgen_name("_swift_leaks_stopTrackingObjects")
318318
func stopTrackingObjects(_: UnsafeMutableRawPointer) -> Int
319319

320320
#endif

cmake/modules/AddSwift.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,11 @@ function(add_swift_library name)
15311531
if("${sdk}" STREQUAL "ANDROID")
15321532
list(APPEND swiftlib_private_link_libraries_targets
15331533
"-latomic")
1534+
# the same issue on FreeBSD, missing symbols:
1535+
# __atomic_store, __atomic_compare_exchange, __atomic_load
1536+
elseif("${sdk}" STREQUAL "FREEBSD")
1537+
list(APPEND swiftlib_private_link_libraries_targets
1538+
"${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${arch}.a")
15341539
endif()
15351540
elseif("${lib}" STREQUAL "ICU_I18N")
15361541
list(APPEND swiftlib_private_link_libraries_targets

docs/DebuggingTheCompiler.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ Abstract
1313
This document contains some useful information for debugging the
1414
Swift compiler and Swift compiler output.
1515

16+
Basic Utilities
17+
---------------
18+
19+
Often, the first step to debug a compiler problem is to re-run the compiler
20+
with a command line, which comes from a crash trace or a build log.
21+
22+
The script ``split-cmdline`` in ``utils/dev-scripts`` splits a command line
23+
into multiple lines. This is helpful to understand and edit long command lines.
24+
1625
Printing the Intermediate Representations
1726
-----------------------------------------
1827

docs/SIL.rst

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,11 @@ Basic Blocks
784784
sil-label ::= sil-identifier ('(' sil-argument (',' sil-argument)* ')')? ':'
785785
sil-argument ::= sil-value-name ':' sil-type
786786

787-
sil-instruction-def ::= (sil-value-name '=')? sil-instruction
788-
(',' sil-loc)? (',' sil-scope-ref)?
787+
sil-instruction-result ::= sil-value-name
788+
sil-instruction-result ::= '(' (sil-value-name (',' sil-value-name)*)? ')'
789+
sil-instruction-source-info ::= (',' sil-scope-ref)? (',' sil-loc)?
790+
sil-instruction-def ::=
791+
(sil-instruction-result '=')? sil-instruction sil-instruction-source-info
789792

790793
A function body consists of one or more basic blocks that correspond
791794
to the nodes of the function's control flow graph. Each basic block
@@ -3506,6 +3509,19 @@ tuple_element_addr
35063509
Given the address of a tuple in memory, derives the
35073510
address of an element within that value.
35083511

3512+
destructure_tuple
3513+
`````````````````
3514+
3515+
::
3516+
3517+
sil-instruction ::= 'destructure_tuple' sil-operand
3518+
3519+
(%elt1, ..., %eltn) = destructure_tuple %0 : $(Elt1Ty, ..., EltNTy)
3520+
// %0 must be a tuple of type $(Elt1Ty, ..., EltNTy)
3521+
// %eltN must have the type $EltNTy
3522+
3523+
Given a tuple value, split the value into its constituent elements.
3524+
35093525
struct
35103526
``````
35113527
::
@@ -3547,6 +3563,19 @@ struct_element_addr
35473563
Given the address of a struct value in memory, derives the address of a
35483564
physical field within the value.
35493565

3566+
destructure_struct
3567+
``````````````````
3568+
3569+
::
3570+
3571+
sil-instruction ::= 'destructure_struct' sil-operand
3572+
3573+
(%elt1, ..., %eltn) = destructure_struct %0 : $S
3574+
// %0 must be a struct of type $S
3575+
// %eltN must have the same type as the Nth field of $S
3576+
3577+
Given a struct, split the struct into its constituant fields.
3578+
35503579
object
35513580
``````
35523581
::

include/swift/AST/DiagnosticsDriver.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ WARNING(verify_debug_info_requires_debug_option,none,
136136
ERROR(error_profile_missing,none,
137137
"no profdata file exists at '%0'", (StringRef))
138138

139+
WARNING(warn_opt_remark_disabled, none,
140+
"Emission of optimization records has been disabled, because it "
141+
"requires a single compiler invocation: consider enabling the "
142+
"-whole-module-optimization flag", ())
143+
139144
#ifndef DIAG_NO_UNDEF
140145
# if defined(DIAG)
141146
# undef DIAG

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ ERROR(expected_parameter_type,PointsToFirstBadToken,
833833
ERROR(expected_parameter_name,PointsToFirstBadToken,
834834
"expected parameter name followed by ':'", ())
835835
ERROR(expected_parameter_colon,PointsToFirstBadToken,
836-
"expected ':' following argumant label and parameter name", ())
836+
"expected ':' following argument label and parameter name", ())
837837
ERROR(missing_parameter_type,PointsToFirstBadToken,
838838
"parameter requires an explicit type", ())
839839
ERROR(multiple_parameter_ellipsis,none,

include/swift/AST/DiagnosticsSema.def

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,17 +1635,18 @@ NOTE(redundant_conformance_witness_ignored,none,
16351635
(DescriptiveDeclKind, DeclName, DeclName))
16361636

16371637
// "Near matches"
1638-
WARNING(optional_req_near_match,none,
1639-
"%0 %1 nearly matches optional requirement %2 of protocol %3",
1640-
(DescriptiveDeclKind, DeclName, DeclName, DeclName))
1638+
WARNING(req_near_match,none,
1639+
"%0 %1 nearly matches %select{defaulted|optional}2 requirement %3 "
1640+
"of protocol %4",
1641+
(DescriptiveDeclKind, DeclName, bool, DeclName, DeclName))
16411642
NOTE(optional_req_nonobjc_near_match_add_objc,none,
16421643
"add '@objc' to provide an Objective-C entrypoint", ())
1643-
NOTE(optional_req_near_match_move,none,
1644+
NOTE(req_near_match_move,none,
16441645
"move %0 to %select{an|another}1 extension to silence this warning",
16451646
(DeclName, unsigned))
1646-
NOTE(optional_req_near_match_nonobjc,none,
1647+
NOTE(req_near_match_nonobjc,none,
16471648
"add '@nonobjc' to silence this %select{warning|error}0", (bool))
1648-
NOTE(optional_req_near_match_access,none,
1649+
NOTE(req_near_match_access,none,
16491650
"make %0 %select{ERROR|private|private|non-public|non-public}1 to silence this "
16501651
"warning", (DeclName, AccessLevel))
16511652

@@ -1924,10 +1925,6 @@ NOTE(override_unnecessary_IUO_use_strict,none,
19241925
NOTE(override_unnecessary_IUO_silence,none,
19251926
"add parentheses to silence this warning", ())
19261927

1927-
ERROR(iuo_in_illegal_position,none,
1928-
"implicitly unwrapped optionals are only allowed at top level and as "
1929-
"function results", ())
1930-
19311928
ERROR(override_mutable_covariant_property,none,
19321929
"cannot override mutable property %0 of type %1 with covariant type %2",
19331930
(Identifier, Type, Type))
@@ -3111,6 +3108,22 @@ ERROR(tuple_single_element,none,
31113108
ERROR(tuple_ellipsis,none,
31123109
"cannot create a variadic tuple", ())
31133110

3111+
WARNING(implicitly_unwrapped_optional_spelling_deprecated,none,
3112+
"the spelling 'ImplicitlyUnwrappedOptional' is deprecated", ())
3113+
3114+
WARNING(implicitly_unwrapped_optional_spelling_deprecated_with_fixit,none,
3115+
"the spelling 'ImplicitlyUnwrappedOptional' is deprecated; use '!' after the type name", ())
3116+
3117+
ERROR(implicitly_unwrapped_optional_spelling_error,none,
3118+
"the spelling 'ImplicitlyUnwrappedOptional' in unsupported; use an explicit type followed by '!'", ())
3119+
3120+
ERROR(implicitly_unwrapped_optional_spelling_error_with_fixit,none,
3121+
"the spelling 'ImplicitlyUnwrappedOptional' is unsupported; use '!' after the type name", ())
3122+
3123+
ERROR(iuo_in_illegal_position,none,
3124+
"implicitly unwrapped optionals are only allowed at top level and as "
3125+
"function results", ())
3126+
31143127
// Ownership
31153128
ERROR(invalid_ownership_type,none,
31163129
"'%select{strong|weak|unowned|unowned}0' may only be applied to "

0 commit comments

Comments
 (0)