Skip to content

Commit d929c74

Browse files
authored
---
yaml --- r: 341983 b: refs/heads/rxwei-patch-1 c: e5e469f h: refs/heads/master i: 341981: 7dfb18b 341979: 99bbbbc 341975: 0cd47b9 341967: 39dc72e 341951: 4c2deab
1 parent aca7898 commit d929c74

File tree

223 files changed

+2415
-1560
lines changed

Some content is hidden

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

223 files changed

+2415
-1560
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: ab8699195840c05ddc9e1e4f0c6d26812f90654b
1018+
refs/heads/rxwei-patch-1: e5e469f330b4d9a168e55f96943bbb082b388003
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/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

branches/rxwei-patch-1/include/swift/AST/Builtins.def

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ BUILTIN_SIL_OPERATION(BeginUnpairedModifyAccess, "beginUnpairedModifyAccess",
314314
/// be a pointer to an UnsafeValueBuffer that records an in progress access.
315315
BUILTIN_SIL_OPERATION(EndUnpairedAccess, "endUnpairedAccess", Special)
316316

317+
/// condfail(Int1) -> ()
318+
/// Triggers a runtime failure if the condition is true.
319+
/// This builtin is deprecated. Use condfail_message instead.
320+
BUILTIN_SIL_OPERATION(LegacyCondFail, "condfail", Special)
321+
317322
/// fixLifetime(T) -> ()
318323
/// Fixes the lifetime of any heap references in a value.
319324
BUILTIN_SIL_OPERATION(FixLifetime, "fixLifetime", Special)
@@ -400,9 +405,9 @@ BUILTIN_RUNTIME_CALL(IsOptionalType, "isOptional", "")
400405
BUILTIN(Id, Name, Attrs)
401406
#endif
402407

403-
/// condfail(Int1, RawPointer) -> ()
408+
/// condfail_message(Int1, RawPointer) -> ()
404409
/// Triggers a runtime failure if the condition is true.
405-
BUILTIN_MISC_OPERATION(CondFail, "condfail", "", Special)
410+
BUILTIN_MISC_OPERATION(CondFailMessage, "condfail_message", "", Special)
406411

407412
/// Sizeof has type T.Type -> Int
408413
BUILTIN_MISC_OPERATION(Sizeof, "sizeof", "n", Special)

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,7 +4105,20 @@ class ProtocolDecl final : public NominalTypeDecl {
41054105
/// by this protocol.
41064106
const Requirement *RequirementSignature = nullptr;
41074107

4108-
bool requiresClassSlow();
4108+
/// Returns the cached result of \c requiresClass or \c None if it hasn't yet
4109+
/// been computed.
4110+
Optional<bool> getCachedRequiresClass() const {
4111+
if (Bits.ProtocolDecl.RequiresClassValid)
4112+
return Bits.ProtocolDecl.RequiresClass;
4113+
4114+
return None;
4115+
}
4116+
4117+
/// Caches the result of \c requiresClass
4118+
void setCachedRequiresClass(bool requiresClass) {
4119+
Bits.ProtocolDecl.RequiresClassValid = true;
4120+
Bits.ProtocolDecl.RequiresClass = requiresClass;
4121+
}
41094122

41104123
bool existentialConformsToSelfSlow();
41114124

@@ -4120,6 +4133,7 @@ class ProtocolDecl final : public NominalTypeDecl {
41204133
friend class SuperclassDeclRequest;
41214134
friend class SuperclassTypeRequest;
41224135
friend class RequirementSignatureRequest;
4136+
friend class ProtocolRequiresClassRequest;
41234137
friend class TypeChecker;
41244138

41254139
public:
@@ -4183,19 +4197,7 @@ class ProtocolDecl final : public NominalTypeDecl {
41834197
}
41844198

41854199
/// True if this protocol can only be conformed to by class types.
4186-
bool requiresClass() const {
4187-
if (Bits.ProtocolDecl.RequiresClassValid)
4188-
return Bits.ProtocolDecl.RequiresClass;
4189-
4190-
return const_cast<ProtocolDecl *>(this)->requiresClassSlow();
4191-
}
4192-
4193-
/// Specify that this protocol is class-bounded, e.g., because it was
4194-
/// annotated with the 'class' keyword.
4195-
void setRequiresClass(bool requiresClass = true) {
4196-
Bits.ProtocolDecl.RequiresClassValid = true;
4197-
Bits.ProtocolDecl.RequiresClass = requiresClass;
4198-
}
4200+
bool requiresClass() const;
41994201

42004202
/// Determine whether an existential conforming to this protocol can be
42014203
/// matched with a generic type parameter constrained to this protocol.

branches/rxwei-patch-1/include/swift/AST/DiagnosticsCommon.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ ERROR(circular_class_inheritance,none,
153153
ERROR(circular_enum_inheritance,none,
154154
"%0 has a raw type that depends on itself", (Identifier))
155155

156+
ERROR(circular_protocol_def,none,
157+
"protocol %0 refines itself", (Identifier))
158+
159+
NOTE(kind_declname_declared_here,none,
160+
"%0 %1 declared here", (DescriptiveDeclKind, DeclName))
161+
156162
#ifndef DIAG_NO_UNDEF
157163
# if defined(DIAG)
158164
# undef DIAG

branches/rxwei-patch-1/include/swift/AST/DiagnosticsParse.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,13 @@ ERROR(extra_rbracket,PointsToFirstBadToken,
762762
"unexpected ']' in type; did you mean to write an array type?", ())
763763
ERROR(extra_colon,PointsToFirstBadToken,
764764
"unexpected ':' in type; did you mean to write a dictionary type?", ())
765+
WARNING(subscript_array_element, none,
766+
"unexpected subscript in array literal; did you mean to write two "
767+
"separate elements instead?", ())
768+
NOTE(subscript_array_element_fix_it_add_comma, none, "add a separator between "
769+
"the elements", ())
770+
NOTE(subscript_array_element_fix_it_remove_space, none,
771+
"remove the space between the elements to silence this warning", ())
765772

766773
// Tuple Types
767774
ERROR(expected_rparen_tuple_type_list,none,
@@ -854,6 +861,8 @@ ERROR(expected_parameter_name,PointsToFirstBadToken,
854861
"expected parameter name followed by ':'", ())
855862
ERROR(expected_parameter_colon,PointsToFirstBadToken,
856863
"expected ':' following argument label and parameter name", ())
864+
ERROR(expected_assignment_instead_of_comparison_operator,none,
865+
"expected '=' instead of '==' to assign default value for parameter", ())
857866
ERROR(missing_parameter_type,PointsToFirstBadToken,
858867
"parameter requires an explicit type", ())
859868
ERROR(multiple_parameter_ellipsis,none,

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
DIAG(NOTE,ID,Options,Text,Signature)
3838
#endif
3939

40-
NOTE(kind_declname_declared_here,none,
41-
"%0 %1 declared here", (DescriptiveDeclKind, DeclName))
4240
NOTE(decl_declared_here,none,
4341
"%0 declared here", (DeclName))
4442
NOTE(kind_declared_here,none,
@@ -2037,8 +2035,6 @@ ERROR(typealias_outside_of_protocol,none,
20372035
"type alias %0 can only be used with a concrete type or "
20382036
"generic parameter base", (Identifier))
20392037

2040-
ERROR(circular_protocol_def,none,
2041-
"protocol %0 refines itself", (Identifier))
20422038
ERROR(objc_protocol_inherits_non_objc_protocol,none,
20432039
"@objc protocol %0 cannot refine non-@objc protocol %1", (Type, Type))
20442040

branches/rxwei-patch-1/include/swift/AST/TypeCheckRequests.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,31 @@ class IsObjCRequest :
176176
void cacheResult(bool value) const;
177177
};
178178

179+
/// Determine whether the given protocol declaration is class-bounded.
180+
class ProtocolRequiresClassRequest:
181+
public SimpleRequest<ProtocolRequiresClassRequest,
182+
bool(ProtocolDecl *),
183+
CacheKind::SeparatelyCached> {
184+
public:
185+
using SimpleRequest::SimpleRequest;
186+
187+
private:
188+
friend SimpleRequest;
189+
190+
// Evaluation.
191+
llvm::Expected<bool> evaluate(Evaluator &evaluator, ProtocolDecl *decl) const;
192+
193+
public:
194+
// Cycle handling.
195+
void diagnoseCycle(DiagnosticEngine &diags) const;
196+
void noteCycleStep(DiagnosticEngine &diags) const;
197+
198+
// Separate caching.
199+
bool isCached() const { return true; }
200+
Optional<bool> getCachedResult() const;
201+
void cacheResult(bool value) const;
202+
};
203+
179204
/// Determine whether the given declaration is 'final'.
180205
class IsFinalRequest :
181206
public SimpleRequest<IsFinalRequest,

branches/rxwei-patch-1/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SWIFT_TYPEID(SuperclassTypeRequest)
1919
SWIFT_TYPEID(EnumRawTypeRequest)
2020
SWIFT_TYPEID(OverriddenDeclsRequest)
2121
SWIFT_TYPEID(IsObjCRequest)
22+
SWIFT_TYPEID(ProtocolRequiresClassRequest)
2223
SWIFT_TYPEID(IsFinalRequest)
2324
SWIFT_TYPEID(IsDynamicRequest)
2425
SWIFT_TYPEID(RequirementRequest)

branches/rxwei-patch-1/include/swift/AST/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ class alignas(1 << TypeAlignInBits) TypeBase {
461461
/// types, optionals, etc.
462462
TypeBase *reconstituteSugar(bool Recursive);
463463

464+
// If this type is a syntax sugar type, desugar it. Also desugar any nested
465+
// syntax sugar types.
466+
TypeBase *getWithoutSyntaxSugar();
467+
464468
/// getASTContext - Return the ASTContext that this type belongs to.
465469
ASTContext &getASTContext() {
466470
// If this type is canonical, it has the ASTContext in it.

branches/rxwei-patch-1/include/swift/ClangImporter/ClangImporterOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class ClangImporterOptions {
100100
/// When set, don't enforce warnings with -Werror.
101101
bool DebuggerSupport = false;
102102

103+
/// When set, clobber the Clang instance's virtual file system with the Swift
104+
/// virtual file system.
105+
bool ForceUseSwiftVirtualFileSystem = false;
106+
103107
/// Return a hash code of any components from these options that should
104108
/// contribute to a Swift Bridging PCH hash.
105109
llvm::hash_code getPCHHashComponents() const {

branches/rxwei-patch-1/include/swift/Parse/Parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,8 @@ class Parser {
14351435

14361436
UnresolvedDeclRefExpr *parseExprOperator();
14371437

1438+
void validateCollectionElement(ParserResult<Expr> element);
1439+
14381440
//===--------------------------------------------------------------------===//
14391441
// Statement Parsing
14401442

branches/rxwei-patch-1/include/swift/Strings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ struct BuiltinNameStringLiteral {
5454
const StringLiteral literal;
5555

5656
constexpr operator StringRef() const { return literal; }
57-
constexpr const StringRef getWithoutPrefix() const {
57+
58+
StringRef getWithoutPrefix() const {
5859
return literal.drop_front(BUILTIN_TYPE_NAME_PREFIX.size());
5960
}
6061
};

0 commit comments

Comments
 (0)