Skip to content

Commit 6507b55

Browse files
authored
---
yaml --- r: 341962 b: refs/heads/rxwei-patch-1 c: 2fdae64 h: refs/heads/master
1 parent 863e032 commit 6507b55

File tree

104 files changed

+2348
-1244
lines changed

Some content is hidden

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

104 files changed

+2348
-1244
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: 71fb2629acfdc05a981aa19e3cc6f93102673a0e
1018+
refs/heads/rxwei-patch-1: 2fdae648b786292f1c2b010165b87e8c421a12bc
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/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/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/DiagnosticsParse.def

Lines changed: 7 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,

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/IDE/IDERequestIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717
SWIFT_TYPEID(CursorInfoRequest)
18+
SWIFT_TYPEID(RangeInfoRequest)

branches/rxwei-patch-1/include/swift/IDE/IDERequests.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "swift/IDE/IDETypeIDs.h"
2424

2525
namespace swift {
26+
//----------------------------------------------------------------------------//
27+
// Cusor info
28+
//----------------------------------------------------------------------------//
2629

2730
// Input for CursorInfoRequest.
2831
// Putting the source file and location together allows us to print the request
@@ -76,6 +79,67 @@ class CursorInfoRequest:
7679
SourceLoc getNearestLoc() const;
7780
};
7881

82+
//----------------------------------------------------------------------------//
83+
// Range info
84+
//----------------------------------------------------------------------------//
85+
86+
// Input for RangeInfoRequest.
87+
// Putting the source file and location together allows us to print the request
88+
// input well e.g. file.swift:3:4
89+
struct RangeInfoOwner {
90+
SourceFile *File;
91+
SourceLoc StartLoc;
92+
SourceLoc EndLoc;
93+
94+
RangeInfoOwner(SourceFile *File, SourceLoc StartLoc, SourceLoc EndLoc):
95+
File(File), StartLoc(StartLoc), EndLoc(EndLoc) {}
96+
RangeInfoOwner(SourceFile *File, unsigned Offset, unsigned Length);
97+
98+
friend llvm::hash_code hash_value(const RangeInfoOwner &CI) {
99+
return hash_combine(hash_value(CI.File),
100+
hash_value(CI.StartLoc.getOpaquePointerValue()),
101+
hash_value(CI.EndLoc.getOpaquePointerValue()));
102+
}
103+
104+
friend bool operator==(const RangeInfoOwner &lhs, const RangeInfoOwner &rhs) {
105+
return lhs.File == rhs.File && lhs.StartLoc == rhs.StartLoc &&
106+
lhs.EndLoc == rhs.EndLoc;
107+
}
108+
109+
friend bool operator!=(const RangeInfoOwner &lhs, const RangeInfoOwner &rhs) {
110+
return !(lhs == rhs);
111+
}
112+
113+
bool isValid() const {
114+
return File && File->getBufferID() && StartLoc.isValid() && EndLoc.isValid();
115+
}
116+
};
117+
118+
void simple_display(llvm::raw_ostream &out, const RangeInfoOwner &owner);
119+
120+
/// Resolve cursor info at a given location.
121+
class RangeInfoRequest:
122+
public SimpleRequest<RangeInfoRequest,
123+
ide::ResolvedRangeInfo(RangeInfoOwner),
124+
CacheKind::Cached>
125+
{
126+
public:
127+
using SimpleRequest::SimpleRequest;
128+
129+
private:
130+
friend SimpleRequest;
131+
132+
// Evaluation.
133+
llvm::Expected<ide::ResolvedRangeInfo> evaluate(Evaluator &evaluator,
134+
RangeInfoOwner CI) const;
135+
136+
public:
137+
// Caching
138+
bool isCached() const { return true; }
139+
// Source location
140+
SourceLoc getNearestLoc() const;
141+
};
142+
79143
/// The zone number for the IDE.
80144
#define SWIFT_IDE_REQUESTS_TYPEID_ZONE 137
81145
#define SWIFT_TYPEID_ZONE SWIFT_IDE_REQUESTS_TYPEID_ZONE

branches/rxwei-patch-1/include/swift/IDE/IDETypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717
SWIFT_TYPEID_NAMED(ide::ResolvedCursorInfo, ResolvedCursorInfo)
18+
SWIFT_TYPEID_NAMED(ide::ResolvedRangeInfo, ResolvedRangeInfo)

branches/rxwei-patch-1/include/swift/IDE/Utils.h

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -368,32 +368,26 @@ struct ResolvedRangeInfo {
368368
TokensInRange, nullptr, /*Commom Expr Parent*/nullptr,
369369
/*Single entry*/true, /*unhandled error*/false,
370370
OrphanKind::None, {}, {}, {}) {}
371-
void print(llvm::raw_ostream &OS);
371+
ResolvedRangeInfo(): ResolvedRangeInfo(ArrayRef<Token>()) {}
372+
void print(llvm::raw_ostream &OS) const;
372373
ExitState exit() const { return ExitInfo.Exit; }
373374
Type getType() const { return ExitInfo.ReturnType; }
374375

376+
friend bool operator==(const ResolvedRangeInfo &lhs,
377+
const ResolvedRangeInfo &rhs) {
378+
if (lhs.TokensInRange.size() != rhs.TokensInRange.size())
379+
return false;
380+
if (lhs.TokensInRange.empty())
381+
return true;
382+
return lhs.TokensInRange.front().getLoc() ==
383+
rhs.TokensInRange.front().getLoc();
384+
}
385+
375386
private:
376387
static CharSourceRange calculateContentRange(ArrayRef<Token> Tokens);
377388
};
378389

379-
class RangeResolver : public SourceEntityWalker {
380-
struct Implementation;
381-
std::unique_ptr<Implementation> Impl;
382-
bool walkToExprPre(Expr *E) override;
383-
bool walkToExprPost(Expr *E) override;
384-
bool walkToStmtPre(Stmt *S) override;
385-
bool walkToStmtPost(Stmt *S) override;
386-
bool walkToDeclPre(Decl *D, CharSourceRange Range) override;
387-
bool walkToDeclPost(Decl *D) override;
388-
bool visitDeclReference(ValueDecl *D, CharSourceRange Range,
389-
TypeDecl *CtorTyRef, ExtensionDecl *ExtTyRef, Type T,
390-
ReferenceMetaData Data) override;
391-
public:
392-
RangeResolver(SourceFile &File, SourceLoc Start, SourceLoc End);
393-
RangeResolver(SourceFile &File, unsigned Offset, unsigned Length);
394-
~RangeResolver();
395-
ResolvedRangeInfo resolve();
396-
};
390+
void simple_display(llvm::raw_ostream &out, const ResolvedRangeInfo &info);
397391

398392
/// This provides a utility to view a printed name by parsing the components
399393
/// of that name. The components include a base name and an array of argument

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
};

branches/rxwei-patch-1/lib/AST/Builtins.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,13 @@ static ValueDecl *getCanBeObjCClassOperation(ASTContext &Context,
10351035
return builder.build(Id);
10361036
}
10371037

1038+
static ValueDecl *getLegacyCondFailOperation(ASTContext &C, Identifier Id) {
1039+
// Int1 -> ()
1040+
auto CondTy = BuiltinIntegerType::get(1, C);
1041+
auto VoidTy = TupleType::getEmpty(C);
1042+
return getBuiltinFunction(Id, {CondTy}, VoidTy);
1043+
}
1044+
10381045
static ValueDecl *getCondFailOperation(ASTContext &C, Identifier Id) {
10391046
// Int1 -> ()
10401047
auto CondTy = BuiltinIntegerType::get(1, C);
@@ -1890,11 +1897,14 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
18901897
if (!Types.empty()) return nullptr;
18911898
return getAddressOfOperation(Context, Id);
18921899

1900+
case BuiltinValueKind::LegacyCondFail:
1901+
return getLegacyCondFailOperation(Context, Id);
1902+
18931903
case BuiltinValueKind::AddressOfBorrow:
18941904
if (!Types.empty()) return nullptr;
18951905
return getAddressOfBorrowOperation(Context, Id);
18961906

1897-
case BuiltinValueKind::CondFail:
1907+
case BuiltinValueKind::CondFailMessage:
18981908
return getCondFailOperation(Context, Id);
18991909

19001910
case BuiltinValueKind::AssertConf:

branches/rxwei-patch-1/lib/AST/DiagnosticEngine.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ static void formatDiagnosticArgument(StringRef Modifier,
468468

469469
// Strip extraneous parentheses; they add no value.
470470
auto type = Arg.getAsType()->getWithoutParens();
471+
472+
// If a type has an unresolved type, print it with syntax sugar removed for
473+
// clarity. For example, print `Array<_>` instead of `[_]`.
474+
if (type->hasUnresolvedType()) {
475+
type = type->getWithoutSyntaxSugar();
476+
}
477+
471478
bool isAmbiguous = typeSpellingIsAmbiguous(type, Args);
472479

473480
if (isAmbiguous && isa<OpaqueTypeArchetypeType>(type.getPointer())) {

0 commit comments

Comments
 (0)