Skip to content

Commit 1862c95

Browse files
authored
Merge pull request #27821 from apple/tensorflow-merge2
Merge swift-DEVELOPMENT-SNAPSHOT-2019-10-13-a into tensorflow
2 parents eaefd71 + 7927f71 commit 1862c95

File tree

260 files changed

+5243
-3155
lines changed

Some content is hidden

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

260 files changed

+5243
-3155
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.swift.gyb linguist-language=Swift
2+
*.cpp.gyb linguist-language=C++

CHANGELOG.md

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -58,63 +58,6 @@ Swift 5.2
5858
(foo as Magic)(5)
5959
```
6060

61-
* [SR-11298][]:
62-
63-
A class-constrained protocol extension, where the extended protocol does
64-
not impose a class constraint, will now infer the constraint implicitly.
65-
66-
```swift
67-
protocol Foo {}
68-
class Bar: Foo {
69-
var someProperty: Int = 0
70-
}
71-
72-
// Even though 'Foo' does not impose a class constraint, it is automatically
73-
// inferred due to the Self: Bar constraint.
74-
extension Foo where Self: Bar {
75-
var anotherProperty: Int {
76-
get { return someProperty }
77-
// As a result, the setter is now implicitly nonmutating, just like it would
78-
// be if 'Foo' had a class constraint.
79-
set { someProperty = newValue }
80-
}
81-
}
82-
```
83-
84-
As a result, this could lead to code that currently compiles today to throw an error.
85-
86-
```swift
87-
protocol Foo {
88-
var someProperty: Int { get set }
89-
}
90-
91-
class Bar: Foo {
92-
var someProperty = 0
93-
}
94-
95-
extension Foo where Self: Bar {
96-
var anotherProperty1: Int {
97-
get { return someProperty }
98-
// This will now error, because the protocol requirement
99-
// is implicitly mutating and the setter is implicitly
100-
// nonmutating.
101-
set { someProperty = newValue } // Error
102-
}
103-
}
104-
```
105-
106-
**Workaround**: Define a new mutable variable inside the setter that has a reference to `self`:
107-
108-
```swift
109-
var anotherProperty1: Int {
110-
get { return someProperty }
111-
set {
112-
var mutableSelf = self
113-
mutableSelf.someProperty = newValue // Okay
114-
}
115-
}
116-
```
117-
11861
* [SE-0253][]:
11962

12063
Values of types that declare `func callAsFunction` methods can be called
@@ -140,7 +83,7 @@ Swift 5.2
14083

14184
* [SR-4206][]:
14285

143-
A method override is no longer allowed to have a generic signature with
86+
A method override is no longer allowed to have a generic signature with
14487
requirements not imposed by the base method. For example:
14588

14689
```
@@ -7856,5 +7799,4 @@ Swift 1.0
78567799
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
78577800
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
78587801
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
7859-
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
78607802
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ endif()
1111
list(APPEND CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1313

14+
set(CMAKE_DISABLE_IN_SOURCE_BUILD YES)
15+
1416
if(DEFINED CMAKE_JOB_POOLS)
1517
# CMake < 3.11 doesn't support CMAKE_JOB_POOLS. Manually set the property.
1618
set_property(GLOBAL PROPERTY JOB_POOLS "${CMAKE_JOB_POOLS}")

cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ function(_compile_swift_files
323323
set(module_base "${module_dir}/${SWIFTFILE_MODULE_NAME}")
324324
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
325325
set(specific_module_dir "${module_base}.swiftmodule")
326-
set(specific_module_private_dir "${specific_module_dir}/Private")
327-
set(source_info_file "${specific_module_private_dir}/${SWIFTFILE_ARCHITECTURE}.swiftsourceinfo")
326+
set(specific_module_project_dir "${specific_module_dir}/Project")
327+
set(source_info_file "${specific_module_project_dir}/${SWIFTFILE_ARCHITECTURE}.swiftsourceinfo")
328328
set(module_base "${module_base}.swiftmodule/${SWIFTFILE_ARCHITECTURE}")
329329
else()
330330
set(specific_module_dir)
331-
set(specific_module_private_dir)
331+
set(specific_module_project_dir)
332332
set(source_info_file "${module_base}.swiftsourceinfo")
333333
endif()
334334
set(module_file "${module_base}.swiftmodule")
@@ -367,7 +367,7 @@ function(_compile_swift_files
367367
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
368368
COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}"
369369
OPTIONAL
370-
PATTERN "Private" EXCLUDE)
370+
PATTERN "Project" EXCLUDE)
371371
else()
372372
swift_install_in_component(FILES ${module_outputs}
373373
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
@@ -508,7 +508,7 @@ function(_compile_swift_files
508508
COMMAND
509509
"${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir}
510510
${specific_module_dir}
511-
${specific_module_private_dir}
511+
${specific_module_project_dir}
512512
COMMAND
513513
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
514514
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"

docs/WindowsBuild.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Pla
9999
Warning: Creating the above links usually requires administrator privileges. The quick and easy way to do this is to open a second developer prompt by right clicking whatever shortcut you used to open the first one, choosing Run As Administrator, and pasting the above commands into the resulting window. You can then close the privileged prompt; this is the only step which requires elevation.
100100

101101
## 6. Build LLVM/Clang
102-
- This must be done from within a developer command prompt. LLVM and Clang are
103-
large projects, so building might take a few hours. Make sure that the build
102+
- This must be done from within a developer command prompt. Make sure that the build
104103
type for LLVM/Clang is compatible with the build type for Swift. That is,
105104
either build everything `Debug` or some variant of `Release` (e.g. `Release`,
106105
`RelWithDebInfo`).
@@ -126,8 +125,8 @@ ninja
126125
path S:\b\llvm\bin;%PATH%
127126
```
128127
## 7. Build CMark
129-
- This must be done from within a developer command prompt. CMark is a fairly
130-
small project and should only take a few minutes to build.
128+
- This must be done from within a developer command prompt.
129+
131130
```cmd
132131
md "S:\b\cmark"
133132
cd "S:\b\cmark"
@@ -180,8 +179,8 @@ cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
180179
```
181180

182181
## 9. Build lldb
183-
- This must be done from within a developer command prompt and could take hours
184-
depending on your system.
182+
- This must be done from within a developer command prompt.
183+
185184
```cmd
186185
md "S:\b\lldb"
187186
cd "S:\b\lldb"

include/swift/AST/ASTScope.h

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "swift/AST/ASTNode.h"
3232
#include "swift/AST/NameLookup.h" // for DeclVisibilityKind
33+
#include "swift/AST/SimpleRequest.h"
3334
#include "swift/Basic/Compiler.h"
3435
#include "swift/Basic/LLVM.h"
3536
#include "swift/Basic/NullablePtr.h"
@@ -88,6 +89,14 @@ struct AnnotatedInsertionPoint {
8889
ASTScopeImpl *insertionPoint;
8990
const char *explanation;
9091
};
92+
} // namespace ast_scope
93+
94+
namespace ast_scope {
95+
96+
void simple_display(llvm::raw_ostream &out, const ASTScopeImpl *);
97+
void simple_display(llvm::raw_ostream &out, const ScopeCreator *);
98+
99+
SourceLoc extractNearestSourceLoc(std::tuple<ASTScopeImpl *, ScopeCreator *>);
91100

92101
#pragma mark the root ASTScopeImpl class
93102

@@ -333,6 +342,11 @@ class ASTScopeImpl {
333342
public:
334343
/// expandScope me, sending deferred nodes to my descendants.
335344
/// Return the scope into which to place subsequent decls
345+
ASTScopeImpl *expandAndBeCurrentDetectingRecursion(ScopeCreator &);
346+
347+
/// Expand or reexpand the scope if unexpanded or if not current.
348+
/// There are several places in the compiler that mutate the AST after the
349+
/// fact, above and beyond adding Decls to the SourceFile.
336350
ASTScopeImpl *expandAndBeCurrent(ScopeCreator &);
337351

338352
unsigned getASTAncestorScopeCount() const { return astAncestorScopeCount; }
@@ -344,6 +358,12 @@ class ASTScopeImpl {
344358
void setWasExpanded() { wasExpanded = true; }
345359
virtual ASTScopeImpl *expandSpecifically(ScopeCreator &) = 0;
346360
virtual void beCurrent();
361+
virtual bool doesExpansionOnlyAddNewDeclsAtEnd() const;
362+
363+
public:
364+
bool isExpansionNeeded(const ScopeCreator &) const;
365+
366+
protected:
347367
bool isCurrent() const;
348368
virtual bool isCurrentIfWasExpanded() const;
349369

@@ -374,16 +394,7 @@ class ASTScopeImpl {
374394

375395
bool isATypeDeclScope() const;
376396

377-
/// There are several places in the compiler that mutate the AST after the
378-
/// fact, above and beyond adding Decls to the SourceFile. These are
379-
/// documented in: rdar://53018839, rdar://53027266, rdar://53027733,
380-
/// rdar://53028050
381-
/// Return true if did reexpand
382-
bool reexpandIfObsolete(ScopeCreator &);
383-
384397
private:
385-
void reexpand(ScopeCreator &);
386-
387398
virtual ScopeCreator &getScopeCreator();
388399

389400
#pragma mark - - creation queries
@@ -533,8 +544,8 @@ class ASTSourceFileScope final : public ASTScopeImpl {
533544
/// The number of \c Decls in the \c SourceFile that were already seen.
534545
/// Since parsing can be interleaved with type-checking, on every
535546
/// lookup, look at creating scopes for any \c Decls beyond this number.
536-
/// rdar://55562483 Unify with numberOfChildrenWhenLastExpanded
537-
int numberOfDeclsAlreadySeen = 0;
547+
/// TODO: Unify with numberOfChildrenWhenLastExpanded
548+
size_t numberOfDeclsAlreadySeen = 0;
538549

539550
ASTSourceFileScope(SourceFile *SF, ScopeCreator *scopeCreator);
540551

@@ -548,7 +559,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
548559
public:
549560
NullablePtr<DeclContext> getDeclContext() const override;
550561

551-
void addNewDeclsToScopeTree();
552562
void buildFullyExpandedTree();
553563
void
554564
buildEnoughOfTreeForTopLevelExpressionsButDontRequestGenericsOrExtendedNominals();
@@ -559,11 +569,15 @@ class ASTSourceFileScope final : public ASTScopeImpl {
559569

560570
protected:
561571
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
572+
bool isCurrentIfWasExpanded() const override;
573+
void beCurrent() override;
574+
bool doesExpansionOnlyAddNewDeclsAtEnd() const override;
562575

563576
ScopeCreator &getScopeCreator() override;
564577

565578
private:
566-
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
579+
AnnotatedInsertionPoint
580+
expandAScopeThatCreatesANewInsertionPoint(ScopeCreator &);
567581
};
568582

569583
class Portion {
@@ -1148,7 +1162,6 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
11481162
/// false positives, that that doesn't hurt anything. However, the result of
11491163
/// the conservative source range computation doesn't seem to be stable. So
11501164
/// keep the original here, and use it for source range queries.
1151-
/// rdar://55263708
11521165

11531166
const SourceRange sourceRangeWhenCreated;
11541167

@@ -1251,7 +1264,6 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
12511264
};
12521265

12531266
class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
1254-
// Should be able to remove this when rdar://53921703 is accomplished.
12551267
Expr *initAsWrittenWhenCreated;
12561268

12571269
public:

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
SWIFT_TYPEID(AncestryFlags)
1919
SWIFT_TYPEID(CtorInitializerKind)
2020
SWIFT_TYPEID(GenericSignature)
21+
SWIFT_TYPEID(ParamSpecifier)
2122
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)
2223
SWIFT_TYPEID(PropertyWrapperTypeInfo)
2324
SWIFT_TYPEID(Requirement)

include/swift/AST/ASTTypeIDs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class ModuleDecl;
3535
class NominalTypeDecl;
3636
class OperatorDecl;
3737
class OpaqueTypeDecl;
38+
class ParamDecl;
39+
enum class ParamSpecifier : uint8_t;
3840
class PrecedenceGroupDecl;
3941
struct PropertyWrapperBackingPropertyInfo;
4042
struct PropertyWrapperTypeInfo;

include/swift/AST/Attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ class DeclAttributes {
20402040
public:
20412041
template <typename ATTR, bool AllowInvalid>
20422042
using AttributeKindRange =
2043-
OptionalTransformRange<llvm::iterator_range<const_iterator>,
2043+
OptionalTransformRange<iterator_range<const_iterator>,
20442044
ToAttributeKind<ATTR, AllowInvalid>,
20452045
const_iterator>;
20462046

0 commit comments

Comments
 (0)