Skip to content

Commit 165bfee

Browse files
authored
---
yaml --- r: 343419 b: refs/heads/master-rebranch c: 27ded64 h: refs/heads/master i: 343417: d95e1f2 343415: 853a426
1 parent 05c8471 commit 165bfee

File tree

91 files changed

+1123
-967
lines changed

Some content is hidden

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

91 files changed

+1123
-967
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 992cc032a7c7b12ca5964bce6a7e0728a0a48ddf
1458+
refs/heads/master-rebranch: 27ded648cf330d32f421c7aadc1ec132f292f556
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SE-0253][]:
30+
31+
Values of types that declare `func callAsFunction` methods can be called
32+
like functions. The call syntax is shorthand for applying
33+
`func callAsFunction` methods.
34+
35+
```swift
36+
struct Adder {
37+
var base: Int
38+
func callAsFunction(_ x: Int) -> Int {
39+
return x + base
40+
}
41+
}
42+
var adder = Adder(base: 3)
43+
adder(10) // returns 13, same as `adder.callAsFunction(10)`
44+
```
45+
46+
* `func callAsFunction` argument labels are required at call sites.
47+
* Multiple `func callAsFunction` methods on a single type are supported.
48+
* `mutating func callAsFunction` is supported.
49+
* `func callAsFunction` works with `throws` and `rethrows`.
50+
* `func callAsFunction` works with trailing closures.
51+
2952
* [SR-4206][]:
3053

3154
A method override is no longer allowed to have a generic signature with
@@ -7711,6 +7734,7 @@ Swift 1.0
77117734
[SE-0244]: <https://github.com/apple/swift-evolution/blob/master/proposals/0244-opaque-result-types.md>
77127735
[SE-0245]: <https://github.com/apple/swift-evolution/blob/master/proposals/0245-array-uninitialized-initializer.md>
77137736
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
7737+
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
77147738
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
77157739

77167740
[SR-106]: <https://bugs.swift.org/browse/SR-106>

branches/master-rebranch/include/swift/AST/ASTContext.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ namespace swift {
6969
class LazyGenericContextData;
7070
class LazyIterableDeclContextData;
7171
class LazyMemberLoader;
72-
class LazyMemberParser;
7372
class LazyResolver;
7473
class PatternBindingDecl;
7574
class PatternBindingInitializer;
@@ -425,12 +424,6 @@ class ASTContext final {
425424
void setLazyResolver(LazyResolver *resolver);
426425

427426
public:
428-
/// Add a lazy parser for resolving members later.
429-
void addLazyParser(LazyMemberParser *parser);
430-
431-
/// Remove a lazy parser.
432-
void removeLazyParser(LazyMemberParser *parser);
433-
434427
/// getIdentifier - Return the uniqued and AST-Context-owned version of the
435428
/// specified string.
436429
Identifier getIdentifier(StringRef Str) const;
@@ -822,12 +815,6 @@ class ASTContext final {
822815
LazyContextData *getOrCreateLazyContextData(const DeclContext *decl,
823816
LazyMemberLoader *lazyLoader);
824817

825-
/// Use the lazy parsers associated with the context to populate the members
826-
/// of the given decl context.
827-
///
828-
/// \param IDC The context whose member decls should be lazily parsed.
829-
std::vector<Decl *> parseMembers(IterableDeclContext *IDC);
830-
831818
/// Get the lazy function data for the given generic context.
832819
///
833820
/// \param lazyLoader If non-null, the lazy loader to use when creating the

branches/master-rebranch/include/swift/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5594,6 +5594,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
55945594
SourceRange BodyRange;
55955595
};
55965596

5597+
friend class ParseAbstractFunctionBodyRequest;
5598+
55975599
CaptureInfo Captures;
55985600

55995601
/// Location of the 'throws' token.

branches/master-rebranch/include/swift/AST/DeclContext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ namespace swift {
5151
class GenericParamList;
5252
class LazyResolver;
5353
class LazyMemberLoader;
54-
class LazyMemberParser;
5554
class GenericSignature;
5655
class GenericTypeParamDecl;
5756
class GenericTypeParamType;

branches/master-rebranch/include/swift/AST/DiagnosticEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ namespace swift {
657657
}
658658

659659
/// Return all \c DiagnosticConsumers.
660-
ArrayRef<DiagnosticConsumer *> getConsumers() {
660+
ArrayRef<DiagnosticConsumer *> getConsumers() const {
661661
return Consumers;
662662
}
663663

branches/master-rebranch/include/swift/AST/DiagnosticSuppression.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class DiagnosticSuppression {
3737
public:
3838
explicit DiagnosticSuppression(DiagnosticEngine &diags);
3939
~DiagnosticSuppression();
40+
static bool isEnabled(const DiagnosticEngine &diags);
4041
};
4142

4243
}

branches/master-rebranch/include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,6 @@ ERROR(cannot_convert_default_arg_value,none,
361361
(Type,Type))
362362
ERROR(cannot_convert_default_arg_value_protocol,none,
363363
"default argument value of type %0 does not conform to %1", (Type,Type))
364-
ERROR(default_argument_literal_cannot_convert, none,
365-
"cannot call %0 %1 because default argument of type %2 cannot be "
366-
"converted to type %3", (DescriptiveDeclKind, DeclName, Type, Type))
367364
ERROR(cannot_convert_default_arg_value_nil,none,
368365
"nil default argument value cannot be converted to type %0", (Type))
369366

@@ -1628,6 +1625,11 @@ NOTE(objc_generic_extension_using_type_parameter_here,none,
16281625
"generic parameter used here", ())
16291626
NOTE(objc_generic_extension_using_type_parameter_try_objc,none,
16301627
"add '@objc' to allow uses of 'self' within the function body", ())
1628+
ERROR(invalid_nominal_extension,none,
1629+
"extension of type %0 must be declared as an extension of %1",
1630+
(Type, Type))
1631+
NOTE(invalid_nominal_extension_rewrite,none,
1632+
"did you mean to extend %0 instead?", (Type))
16311633

16321634
// Protocols
16331635
ERROR(type_does_not_conform,none,

branches/master-rebranch/include/swift/AST/Identifier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class DeclName {
590590
llvm::raw_ostream &printPretty(llvm::raw_ostream &os) const;
591591

592592
/// Dump this name to standard error.
593-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
593+
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
594594
"only for use within the debugger");
595595
};
596596

@@ -672,7 +672,7 @@ class ObjCSelector {
672672
}
673673

674674
/// Dump this selector to standard error.
675-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
675+
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
676676
"only for use within the debugger");
677677

678678
/// Compare two Objective-C selectors, producing -1 if \c *this comes before

branches/master-rebranch/include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,6 @@ class LazyContextData {
8585
LazyMemberLoader *loader;
8686
};
8787

88-
/// A class that can lazily parse members for an iterable decl context.
89-
class LazyMemberParser {
90-
public:
91-
virtual ~LazyMemberParser() = default;
92-
93-
/// Retrieves the parsed members for the given decl context \p IDC.
94-
virtual std::vector<Decl *> parseMembers(IterableDeclContext *IDC) = 0;
95-
96-
/// Return whether the iterable decl context needs parsing.
97-
virtual bool hasUnparsedMembers(const IterableDeclContext *IDC) = 0;
98-
99-
/// Parse all delayed decl list members.
100-
virtual void parseAllDelayedDeclLists() = 0;
101-
};
102-
10388
/// Context data for generic contexts.
10489
class LazyGenericContextData : public LazyContextData {
10590
public:

branches/master-rebranch/include/swift/AST/ParseRequests.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@ class ParseMembersRequest :
4848
bool isCached() const { return true; }
4949
};
5050

51+
/// Parse the body of a function, initializer, or deinitializer.
52+
class ParseAbstractFunctionBodyRequest :
53+
public SimpleRequest<ParseAbstractFunctionBodyRequest,
54+
BraceStmt *(AbstractFunctionDecl *),
55+
CacheKind::SeparatelyCached>
56+
{
57+
public:
58+
using SimpleRequest::SimpleRequest;
59+
60+
private:
61+
friend SimpleRequest;
62+
63+
// Evaluation.
64+
BraceStmt *evaluate(Evaluator &evaluator, AbstractFunctionDecl *afd) const;
65+
66+
public:
67+
// Caching
68+
bool isCached() const { return true; }
69+
Optional<BraceStmt *> getCachedResult() const;
70+
void cacheResult(BraceStmt *value) const;
71+
};
72+
5173
/// The zone number for the parser.
5274
#define SWIFT_TYPEID_ZONE Parse
5375
#define SWIFT_TYPEID_HEADER "swift/AST/ParseTypeIDZone.def"

branches/master-rebranch/include/swift/AST/ParseTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
SWIFT_REQUEST(Parse, ParseMembersRequest)
18+
SWIFT_REQUEST(Parse, ParseAbstractFunctionBodyRequest)

branches/master-rebranch/include/swift/Frontend/Frontend.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ class CompilerInstance {
616616

617617
private:
618618
void createREPLFile(const ImplicitImports &implicitImports);
619-
std::unique_ptr<DelayedParsingCallbacks> computeDelayedParsingCallback();
620619

621620
void addMainFileToModule(const ImplicitImports &implicitImports);
622621

@@ -625,20 +624,17 @@ class CompilerInstance {
625624
SourceFile::ASTStage_t LimitStage);
626625

627626
void parseLibraryFile(unsigned BufferID,
628-
const ImplicitImports &implicitImports,
629-
DelayedParsingCallbacks *DelayedCB);
627+
const ImplicitImports &implicitImports);
630628

631629
/// Return true if had load error
632630
bool
633-
parsePartialModulesAndLibraryFiles(const ImplicitImports &implicitImports,
634-
DelayedParsingCallbacks *DelayedCB);
631+
parsePartialModulesAndLibraryFiles(const ImplicitImports &implicitImports);
635632

636633
OptionSet<TypeCheckingFlags> computeTypeCheckingOptions();
637634

638635
void forEachFileToTypeCheck(llvm::function_ref<void(SourceFile &)> fn);
639636

640637
void parseAndTypeCheckMainFileUpTo(SourceFile::ASTStage_t LimitStage,
641-
DelayedParsingCallbacks *DelayedParseCB,
642638
OptionSet<TypeCheckingFlags> TypeCheckOptions);
643639

644640
void finishTypeChecking(OptionSet<TypeCheckingFlags> TypeCheckOptions);

branches/master-rebranch/include/swift/Parse/DelayedParsingCallbacks.h

Lines changed: 0 additions & 59 deletions
This file was deleted.

branches/master-rebranch/include/swift/Parse/Parser.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ namespace llvm {
4646
namespace swift {
4747
class CodeCompletionCallbacks;
4848
class DefaultArgumentInitializer;
49-
class DelayedParsingCallbacks;
5049
class DiagnosticEngine;
5150
class Expr;
5251
class Lexer;
@@ -165,14 +164,8 @@ class Parser {
165164

166165
LocalContext *CurLocalContext = nullptr;
167166

168-
DelayedParsingCallbacks *DelayedParseCB = nullptr;
169-
170167
bool isDelayedParsingEnabled() const {
171-
return DelayBodyParsing || DelayedParseCB != nullptr;
172-
}
173-
174-
void setDelayedParsingCallbacks(DelayedParsingCallbacks *DelayedParseCB) {
175-
this->DelayedParseCB = DelayedParseCB;
168+
return DelayBodyParsing || SourceMgr.getCodeCompletionLoc().isValid();
176169
}
177170

178171
void setCodeCompletionCallbacks(CodeCompletionCallbacks *Callbacks) {
@@ -976,15 +969,12 @@ class Parser {
976969
bool parseMemberDeclList(SourceLoc LBLoc, SourceLoc &RBLoc,
977970
SourceLoc PosBeforeLB,
978971
Diag<> ErrorDiag,
979-
ParseDeclOptions Options,
980972
IterableDeclContext *IDC);
981973

982974
bool canDelayMemberDeclParsing(bool &HasOperatorDeclarations,
983975
bool &HasNestedClassDeclarations);
984976

985977
bool delayParsingDeclList(SourceLoc LBLoc, SourceLoc &RBLoc,
986-
SourceLoc PosBeforeLB,
987-
ParseDeclOptions Options,
988978
IterableDeclContext *IDC);
989979

990980
ParserResult<TypeDecl> parseDeclTypeAlias(ParseDeclOptions Flags,
@@ -1127,7 +1117,7 @@ class Parser {
11271117
DeclAttributes &Attributes,
11281118
bool HasFuncKeyword = true);
11291119
void parseAbstractFunctionBody(AbstractFunctionDecl *AFD);
1130-
bool parseAbstractFunctionBodyDelayed(AbstractFunctionDecl *AFD);
1120+
BraceStmt *parseAbstractFunctionBodyDelayed(AbstractFunctionDecl *AFD);
11311121
ParserResult<ProtocolDecl> parseDeclProtocol(ParseDeclOptions Flags,
11321122
DeclAttributes &Attributes);
11331123

0 commit comments

Comments
 (0)