Skip to content

Commit d050ae7

Browse files
authored
Merge pull request #1990 from swiftwasm/katei/merge-main-2020-10-12
Merge main 2020-10-12
2 parents 16639f9 + 546a58a commit d050ae7

File tree

336 files changed

+9360
-4398
lines changed

Some content is hidden

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

336 files changed

+9360
-4398
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ CHANGELOG
2727
Swift Next
2828
----------
2929

30+
* [SR-10069][]:
31+
32+
Function overloading now works in local contexts, making the following valid:
33+
34+
```swift
35+
func outer(x: Int, y: String) {
36+
func doIt(_: Int) {}
37+
func doIt(_: String) {}
38+
39+
doIt(x) // calls the first 'doIt(_:)' with an Int value
40+
doIt(y) // calls the second 'doIt(_:)' with a String value
41+
}
42+
```
43+
3044
* [SE-0284][]:
3145

3246
Functions, subscripts, and initializers may now have more than one variadic parameter, as long as all parameters which follow variadic parameters are labeled. This makes declarations like the following valid:
@@ -8196,6 +8210,7 @@ Swift 1.0
81968210
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
81978211
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
81988212
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
8213+
[SR-10069]: <https://bugs.swift.org/browse/SR-10069>
81998214
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
82008215
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>
82018216
[SR-11700]: <https://bugs.swift.org/browse/SR-11700>

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ Function Specializations
995995
::
996996

997997
specialization ::= type '_' type* 'Tg' SPEC-INFO // Generic re-abstracted specialization
998+
specialization ::= type '_' type* 'Ts' SPEC-INFO // Generic re-abstracted prespecialization
998999
specialization ::= type '_' type* 'TG' SPEC-INFO // Generic not re-abstracted specialization
9991000
specialization ::= type '_' type* 'Ti' SPEC-INFO // Inlined function with generic substitutions.
10001001

docs/HowToGuides/GettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ toolchain as a one-off, there are a couple of differences:
9797
or a specific snapshot. You can update the branch/tag for all repositories
9898
as follows:
9999
```sh
100-
utils/update-checkout --branch mybranchname
100+
utils/update-checkout --scheme mybranchname
101101
# OR
102102
utils/update-checkout --tag mytagname
103103
```

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ documentation, please create a thread on the Swift forums under the
120120
lazy type-checking and efficient caching.
121121
- [Literals.md](/docs/Literals.md):
122122
Describes type-checking and inference specifically for literals.
123-
- [Serialization.rst](/docs/Serialization.rst):
123+
- [Serialization.md](/docs/Serialization.md):
124124
Gives an overview of the LLVM bitcode format used for swiftmodules.
125125
- [StableBitcode.md](/docs/StableBitcode.md):
126126
Describes how to maintain compatibility when changing the serialization

docs/Serialization.rst renamed to docs/Serialization.md

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
:orphan:
2-
3-
=================================
4-
Swift Binary Serialization Format
5-
=================================
1+
# Swift Binary Serialization Format
62

73
The fundamental unit of distribution for Swift code is a *module.* A module
84
contains declarations as an interface for clients to write code against. It may
@@ -33,10 +29,9 @@ tied to the compiler internals to be useful for this purpose, and it is likely
3329
we'll invent a new format instead.
3430

3531

36-
Why LLVM bitcode?
37-
=================
32+
## Why LLVM bitcode?
3833

39-
The `LLVM bitstream <http://llvm.org/docs/BitCodeFormat.html>`_ format was
34+
The [LLVM bitstream](http://llvm.org/docs/BitCodeFormat.html) format was
4035
invented as a container format for LLVM IR. It is a binary format supporting
4136
two basic structures: *blocks,* which define regions of the file, and
4237
*records,* which contain data fields that can be up to 64 bits. It has a few
@@ -60,10 +55,9 @@ have most of these properties as well. But we're already linking against
6055
LLVM...might as well use it!
6156

6257

63-
Versioning
64-
==========
58+
## Versioning
6559

66-
.. warning::
60+
#### _Warning_
6761

6862
This section is relevant to any forward-compatible format used for a
6963
library's public interface. However, as mentioned above this may not be
@@ -101,13 +95,11 @@ requires extra work on the compiler's part to detect which features are in use;
10195
a simpler implementation would just use the latest version number supported:
10296
1.9.
10397

104-
*This versioning scheme was inspired by* `Semantic Versioning
105-
<http://semver.org>`_. *However, it is not compatible with Semantic Versioning
98+
*This versioning scheme was inspired by* [Semantic Versioning](http://semver.org). *However, it is not compatible with Semantic Versioning
10699
because it promises* forward-compatibility *rather than* backward-compatibility.
107100

108101

109-
A High-Level Tour of the Current Module Format
110-
==============================================
102+
## A High-Level Tour of the Current Module Format
111103

112104
Every serialized module is represented as a single block called the "module
113105
block". The module block is made up of several other block kinds, largely for
@@ -132,7 +124,7 @@ organizational purposes.
132124
- The **SIL block** contains SIL-level implementations that can be imported
133125
into a client's SILModule context. In most cases this is just a performance
134126
concern, but sometimes it affects language semantics as well, as in the case
135-
of ``@_transparent``. The SIL block precedes the AST block because it affects
127+
of `@_transparent`. The SIL block precedes the AST block because it affects
136128
which AST nodes get serialized.
137129

138130
- The **SIL index block** contains tables for accessing various SIL entities by
@@ -145,9 +137,7 @@ organizational purposes.
145137
Nodes are accessed by a file-unique "DeclIDs" (also covering DeclContexts)
146138
and "TypeIDs"; the two sets of IDs use separate numbering schemes.
147139

148-
.. note::
149-
150-
The AST block is currently referred to as the "decls block" in the source.
140+
_note_: The AST block is currently referred to as the "decls block" in the source.
151141

152142
- The **identifier block** contains a single blob of strings. This is intended
153143
for Identifiers---strings uniqued by the ASTContext---but can in theory
@@ -160,13 +150,11 @@ organizational purposes.
160150
top-level declarations.
161151

162152

163-
SIL
164-
===
153+
## SIL
165154

166155
[to be written]
167156

168157

169-
Cross-reference resilience
170-
==========================
158+
## Cross-reference resilience
171159

172160
[to be written]

include/swift/AST/ASTScope.h

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ class ASTScopeImpl {
194194
#pragma mark - source ranges
195195

196196
public:
197-
/// Return signum of ranges. Centralize the invariant that ASTScopes use ends.
198-
static int compare(SourceRange, SourceRange, const SourceManager &,
199-
bool ensureDisjoint);
200-
201197
CharSourceRange getCharSourceRangeOfScope(SourceManager &SM,
202198
bool omitAssertions = false) const;
203199
bool isCharSourceRangeCached() const;
@@ -224,7 +220,6 @@ class ASTScopeImpl {
224220
virtual NullablePtr<DeclAttribute> getDeclAttributeIfAny() const {
225221
return nullptr;
226222
}
227-
virtual NullablePtr<const void> getReferrent() const { return nullptr; }
228223

229224
#pragma mark - debugging and printing
230225

@@ -402,7 +397,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
402397
public:
403398
SourceFile *const SF;
404399
ScopeCreator *const scopeCreator;
405-
ASTScopeImpl *insertionPoint;
406400

407401
ASTSourceFileScope(SourceFile *SF, ScopeCreator *scopeCreator);
408402

@@ -470,9 +464,6 @@ class Portion {
470464
virtual NullablePtr<const ASTScopeImpl>
471465
getLookupLimitFor(const GenericTypeOrExtensionScope *) const;
472466

473-
virtual const Decl *
474-
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const;
475-
476467
virtual NullablePtr<ASTScopeImpl>
477468
insertionPointForDeferredExpansion(IterableTypeScope *) const = 0;
478469
};
@@ -493,9 +484,6 @@ class Portion {
493484
NullablePtr<const ASTScopeImpl>
494485
getLookupLimitFor(const GenericTypeOrExtensionScope *) const override;
495486

496-
const Decl *
497-
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const override;
498-
499487
NullablePtr<ASTScopeImpl>
500488
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
501489
};
@@ -570,7 +558,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
570558

571559
virtual Decl *getDecl() const = 0;
572560
NullablePtr<Decl> getDeclIfAny() const override { return getDecl(); }
573-
NullablePtr<const void> getReferrent() const override;
574561

575562
private:
576563
AnnotatedInsertionPoint
@@ -745,7 +732,6 @@ class GenericParamScope final : public ASTScopeImpl {
745732

746733
/// Actually holder is always a GenericContext, need to test if
747734
/// ProtocolDecl or SubscriptDecl but will refactor later.
748-
NullablePtr<const void> getReferrent() const override;
749735
std::string getClassName() const override;
750736
SourceRange
751737
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
@@ -788,8 +774,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
788774
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
789775
Decl *getDecl() const { return decl; }
790776

791-
NullablePtr<const void> getReferrent() const override;
792-
793777
protected:
794778
NullablePtr<const GenericParamList> genericParams() const override;
795779
};
@@ -813,7 +797,6 @@ class ParameterListScope final : public ASTScopeImpl {
813797

814798
private:
815799
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
816-
SourceLoc fixupEndForBadInput(SourceRange) const;
817800

818801
public:
819802
std::string getClassName() const override;
@@ -902,7 +885,6 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
902885
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
903886
return attr;
904887
}
905-
NullablePtr<const void> getReferrent() const override;
906888

907889
private:
908890
void expandAScopeThatDoesNotCreateANewInsertionPoint(ScopeCreator &);
@@ -970,8 +952,6 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
970952
SourceRange
971953
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
972954

973-
NullablePtr<const void> getReferrent() const override;
974-
975955
protected:
976956
bool lookupLocalsOrMembers(DeclConsumer) const override;
977957
bool isLabeledStmtLookupTerminator() const override;
@@ -1072,7 +1052,6 @@ class CaptureListScope final : public ASTScopeImpl {
10721052
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
10731053
NullablePtr<Expr> getExprIfAny() const override { return expr; }
10741054
Expr *getExpr() const { return expr; }
1075-
NullablePtr<const void> getReferrent() const override;
10761055
bool lookupLocalsOrMembers(DeclConsumer) const override;
10771056
};
10781057

@@ -1094,7 +1073,6 @@ class ClosureParametersScope final : public ASTScopeImpl {
10941073
}
10951074
NullablePtr<Expr> getExprIfAny() const override { return closureExpr; }
10961075
Expr *getExpr() const { return closureExpr; }
1097-
NullablePtr<const void> getReferrent() const override;
10981076

10991077
protected:
11001078
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
@@ -1128,7 +1106,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
11281106
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
11291107
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
11301108
Decl *getDecl() const { return decl; }
1131-
NullablePtr<const void> getReferrent() const override;
11321109
};
11331110

11341111
/// The \c _@specialize attribute.
@@ -1153,7 +1130,6 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
11531130
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
11541131
return specializeAttr;
11551132
}
1156-
NullablePtr<const void> getReferrent() const override;
11571133

11581134
protected:
11591135
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
@@ -1183,7 +1159,6 @@ class DifferentiableAttributeScope final : public ASTScopeImpl {
11831159
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
11841160
return differentiableAttr;
11851161
}
1186-
NullablePtr<const void> getReferrent() const override;
11871162

11881163
protected:
11891164
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
@@ -1214,7 +1189,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
12141189
public:
12151190
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
12161191
Decl *getDecl() const { return decl; }
1217-
NullablePtr<const void> getReferrent() const override;
12181192

12191193
protected:
12201194
NullablePtr<const GenericParamList> genericParams() const override;
@@ -1244,7 +1218,6 @@ class AbstractStmtScope : public ASTScopeImpl {
12441218
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
12451219
virtual Stmt *getStmt() const = 0;
12461220
NullablePtr<Stmt> getStmtIfAny() const override { return getStmt(); }
1247-
NullablePtr<const void> getReferrent() const override;
12481221

12491222
protected:
12501223
bool isLabeledStmtLookupTerminator() const override;
@@ -1559,11 +1532,11 @@ class BraceStmtScope final : public AbstractStmtScope {
15591532
BraceStmt *const stmt;
15601533

15611534
/// Declarations which are in scope from the beginning of the statement.
1562-
SmallVector<ValueDecl *, 2> localFuncsAndTypes;
1535+
ArrayRef<ValueDecl *> localFuncsAndTypes;
15631536

15641537
/// Declarations that are normally in scope only after their
15651538
/// definition.
1566-
SmallVector<VarDecl *, 2> localVars;
1539+
ArrayRef<VarDecl *> localVars;
15671540

15681541
/// The end location for bindings introduced in this scope. This can
15691542
/// extend past the actual end of the BraceStmt in top-level code,
@@ -1573,8 +1546,8 @@ class BraceStmtScope final : public AbstractStmtScope {
15731546

15741547
public:
15751548
BraceStmtScope(BraceStmt *e,
1576-
SmallVector<ValueDecl *, 2> localFuncsAndTypes,
1577-
SmallVector<VarDecl *, 2> localVars,
1549+
ArrayRef<ValueDecl *> localFuncsAndTypes,
1550+
ArrayRef<VarDecl *> localVars,
15781551
SourceLoc endLoc)
15791552
: stmt(e),
15801553
localFuncsAndTypes(localFuncsAndTypes),

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SWIFT_TYPEID(BodyInitKindAndExpr)
2222
SWIFT_TYPEID(CtorInitializerKind)
2323
SWIFT_TYPEID(FunctionBuilderBodyPreCheck)
2424
SWIFT_TYPEID(GenericSignature)
25-
SWIFT_TYPEID(ImplicitImport)
25+
SWIFT_TYPEID(ImplicitImportList)
2626
SWIFT_TYPEID(ImplicitMemberAction)
2727
SWIFT_TYPEID(ParamSpecifier)
2828
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class GenericTypeParamType;
4242
class InfixOperatorDecl;
4343
class IterableDeclContext;
4444
class ModuleDecl;
45-
struct ImplicitImport;
45+
struct ImplicitImportList;
4646
class NamedPattern;
4747
class NominalTypeDecl;
4848
class OperatorDecl;

0 commit comments

Comments
 (0)