Merge pull request #13618 from slavapestov/class-resilience-part-9
Class resilience part 9
diff --git a/include/swift/Parse/Parser.h b/include/swift/Parse/Parser.h
index 94e4c2b..f72e0c4 100644
--- a/include/swift/Parse/Parser.h
+++ b/include/swift/Parse/Parser.h
@@ -710,11 +710,6 @@
/// Options that control the parsing of declarations.
typedef OptionSet<ParseDeclFlags> ParseDeclOptions;
- /// Skips the current token if it is '}', and emits a diagnostic.
- ///
- /// \returns true if any tokens were skipped.
- bool skipExtraTopLevelRBraces();
-
void delayParseFromBeginningToHere(ParserPosition BeginParserPosition,
ParseDeclOptions Flags);
void consumeDecl(ParserPosition BeginParserPosition, ParseDeclOptions Flags,
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index d391b9c..7c537a7 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -196,8 +196,6 @@
// Parse the body of the file.
SmallVector<ASTNode, 128> Items;
- skipExtraTopLevelRBraces();
-
// If we are in SIL mode, and if the first token is the start of a sil
// declaration, parse that one SIL function and return to the top level. This
// allows type declarations and other things to be parsed, name bound, and
@@ -280,19 +278,6 @@
return FoundTopLevelCodeToExecute;
}
-bool Parser::skipExtraTopLevelRBraces() {
- if (!Tok.is(tok::r_brace))
- return false;
- while (Tok.is(tok::r_brace)) {
- diagnose(Tok, diag::extra_rbrace)
- .fixItRemove(Tok.getLoc());
- consumeToken();
- }
- return true;
-}
-
-
-
static Optional<StringRef>
getStringLiteralIfNotInterpolated(Parser &P, SourceLoc Loc, const Token &Tok,
StringRef DiagText) {
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 7a49db4..49a5b07 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -834,6 +834,7 @@
/// expr-super-subscript:
/// 'super' '[' expr ']'
ParserResult<Expr> Parser::parseExprSuper(bool isExprBasic) {
+ SyntaxParsingContext SuperCtxt(SyntaxContext, SyntaxContextKind::Expr);
// Parse the 'super' reference.
SourceLoc superLoc = consumeToken(tok::kw_super);
@@ -842,6 +843,7 @@
superLoc);
bool ErrorOccurred = selfDecl == nullptr;
+ SyntaxContext->createNodeInPlace(SyntaxKind::SuperRefExpr);
Expr *superRef = !ErrorOccurred
? cast<Expr>(new (Context) SuperRefExpr(selfDecl, superLoc,
/*Implicit=*/false))
@@ -869,6 +871,7 @@
if (!name)
return nullptr;
+ SyntaxContext->createNodeInPlace(SyntaxKind::MemberAccessExpr);
return makeParserResult(
new (Context) UnresolvedDotExpr(superRef, dotLoc, name, nameLoc,
/*Implicit=*/false));
@@ -896,11 +899,12 @@
indexArgLabelLocs,
rSquareLoc,
trailingClosure,
- SyntaxKind::Unknown);
+ SyntaxKind::FunctionCallArgumentList);
if (status.hasCodeCompletion())
return makeParserCodeCompletionResult<Expr>();
if (status.isError())
return nullptr;
+ SyntaxContext->createNodeInPlace(SyntaxKind::SubscriptExpr);
return makeParserResult(
SubscriptExpr::create(Context, superRef, lSquareLoc, indexArgs,
indexArgLabels, indexArgLabelLocs, rSquareLoc,
@@ -1120,6 +1124,7 @@
break;
}
+ Tok.setKind(tok::period);
consumeToken();
// Handle "x.42" - a tuple index.
@@ -1222,6 +1227,7 @@
// If there is an expr-call-suffix, parse it and form a call.
if (Tok.isFollowingLParen()) {
Result = parseExprCallSuffix(Result, isExprBasic);
+ SyntaxContext->createNodeInPlace(SyntaxKind::FunctionCallExpr);
continue;
}
@@ -1246,7 +1252,7 @@
tok::l_square, tok::r_square,
/*isPostfix=*/true, isExprBasic, lSquareLoc, indexArgs,
indexArgLabels, indexArgLabelLocs, rSquareLoc, trailingClosure,
- SyntaxKind::Unknown);
+ SyntaxKind::FunctionCallArgumentList);
if (status.hasCodeCompletion())
return makeParserCodeCompletionResult<Expr>();
if (status.isError() || Result.isNull())
@@ -1255,6 +1261,7 @@
Context, Result.get(), lSquareLoc, indexArgs, indexArgLabels,
indexArgLabelLocs, rSquareLoc, trailingClosure, ConcreteDeclRef(),
/*implicit=*/false));
+ SyntaxContext->createNodeInPlace(SyntaxKind::SubscriptExpr);
continue;
}
@@ -1268,6 +1275,12 @@
isa<TupleExpr>(callee))
break;
+ if (SyntaxContext->isEnabled()) {
+ // Add dummy blank argument list to the call expression syntax.
+ SyntaxContext->addSyntax(
+ SyntaxFactory::makeBlankFunctionCallArgumentList());
+ }
+
ParserResult<Expr> closure =
parseTrailingClosure(callee->getSourceRange());
if (closure.isNull())
@@ -1278,6 +1291,7 @@
ParserStatus(closure),
CallExpr::create(Context, Result.get(), SourceLoc(), {}, {}, {},
SourceLoc(), closure.get(), /*implicit=*/false));
+ SyntaxContext->createNodeInPlace(SyntaxKind::FunctionCallExpr);
if (Result.hasCodeCompletion())
return Result;
@@ -1293,6 +1307,7 @@
if (consumeIf(tok::question_postfix)) {
Result = makeParserResult(
new (Context) BindOptionalExpr(Result.get(), TokLoc, /*depth*/ 0));
+ SyntaxContext->createNodeInPlace(SyntaxKind::OptionalChainingExpr);
hasBindOptional = true;
continue;
}
@@ -1301,6 +1316,7 @@
if (consumeIf(tok::exclaim_postfix)) {
Result =
makeParserResult(new (Context) ForceValueExpr(Result.get(), TokLoc));
+ SyntaxContext->createNodeInPlace(SyntaxKind::ForcedValueExpr);
continue;
}
@@ -1314,6 +1330,7 @@
Expr *oper = parseExprOperator();
Result =
makeParserResult(new (Context) PostfixUnaryExpr(oper, Result.get()));
+ SyntaxContext->createNodeInPlace(SyntaxKind::PostfixUnaryExpr);
continue;
}
@@ -1566,6 +1583,7 @@
// If there is an expr-call-suffix, parse it and form a call.
if (Tok.isFollowingLParen()) {
Result = parseExprCallSuffix(Result, isExprBasic);
+ SyntaxContext->createNodeInPlace(SyntaxKind::FunctionCallExpr);
break;
}
@@ -1606,6 +1624,7 @@
case tok::period: //=.foo
case tok::period_prefix: { // .foo
+ Tok.setKind(tok::period_prefix);
SourceLoc DotLoc = consumeToken();
// Special case ".<integer_literal>" like ".4". This isn't valid, but the
@@ -1665,6 +1684,7 @@
Name = parseUnqualifiedDeclName(/*afterDot=*/true, NameLoc,
diag::expected_identifier_after_dot_expr);
if (!Name) return nullptr;
+ SyntaxContext->createNodeInPlace(SyntaxKind::ImplicitMemberExpr);
// Check for a () suffix, which indicates a call when constructing
// this member. Note that this cannot be the start of a new line.
@@ -1685,6 +1705,7 @@
if (status.isError())
return nullptr;
+ SyntaxContext->createNodeInPlace(SyntaxKind::FunctionCallExpr);
Result = makeParserResult(
status,
UnresolvedMemberExpr::create(Context, DotLoc, NameLoc, Name,
@@ -1699,10 +1720,17 @@
// Check for a trailing closure, if allowed.
if (Tok.is(tok::l_brace) && isValidTrailingClosure(isExprBasic, *this)) {
+ if (SyntaxContext->isEnabled()) {
+ // Add dummy blank argument list to the call expression syntax.
+ SyntaxContext->addSyntax(
+ SyntaxFactory::makeBlankFunctionCallArgumentList());
+ }
+
ParserResult<Expr> closure =
parseTrailingClosure(NameLoc.getSourceRange());
if (closure.isNull()) return nullptr;
+ SyntaxContext->createNodeInPlace(SyntaxKind::FunctionCallExpr);
// Handle .foo by just making an AST node.
Result = makeParserResult(
ParserStatus(closure),
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 131218d..357cf9d 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -245,11 +245,9 @@
}
ParserStatus BraceItemsStatus;
- SmallVector<Decl*, 8> TmpDecls;
bool PreviousHadSemi = true;
- while ((Kind == BraceItemListKind::TopLevelLibrary ||
- Tok.isNot(tok::r_brace)) &&
+ while ((IsTopLevel || Tok.isNot(tok::r_brace)) &&
Tok.isNot(tok::pound_endif) &&
Tok.isNot(tok::pound_elseif) &&
Tok.isNot(tok::pound_else) &&
@@ -266,9 +264,13 @@
SyntaxParsingContext StmtContext(SyntaxContext, SyntaxContextKind::Stmt);
- if (Kind == BraceItemListKind::TopLevelLibrary &&
- skipExtraTopLevelRBraces())
+ if (Tok.is(tok::r_brace)) {
+ assert(IsTopLevel);
+ diagnose(Tok, diag::extra_rbrace)
+ .fixItRemove(Tok.getLoc());
+ consumeToken();
continue;
+ }
// Eat invalid tokens instead of allowing them to produce downstream errors.
if (consumeIf(tok::unknown))
@@ -292,9 +294,40 @@
// Parse the decl, stmt, or expression.
PreviousHadSemi = false;
- if (isStartOfDecl()
- && Tok.isNot(
- tok::pound_if, tok::pound_sourceLocation, tok::pound_line)) {
+ if (Tok.is(tok::pound_if)) {
+ auto IfConfigResult = parseIfConfig(
+ [&](SmallVectorImpl<ASTNode> &Elements, bool IsActive) {
+ parseBraceItems(Elements, Kind, IsActive
+ ? BraceItemListKind::ActiveConditionalBlock
+ : BraceItemListKind::InactiveConditionalBlock);
+ });
+ if (auto ICD = IfConfigResult.getPtrOrNull()) {
+ Result = ICD;
+ // Add the #if block itself
+ Entries.push_back(ICD);
+
+ for (auto &Entry : ICD->getActiveClauseElements()) {
+ if (Entry.is<Decl *>() && isa<IfConfigDecl>(Entry.get<Decl *>()))
+ // Don't hoist nested '#if'.
+ continue;
+ Entries.push_back(Entry);
+ if (Entry.is<Decl *>())
+ Entry.get<Decl *>()->setEscapedFromIfConfig(true);
+ }
+ } else {
+ NeedParseErrorRecovery = true;
+ continue;
+ }
+ } else if (Tok.is(tok::pound_line)) {
+ ParserStatus Status = parseLineDirective(true);
+ BraceItemsStatus |= Status;
+ NeedParseErrorRecovery = Status.isError();
+ } else if (Tok.is(tok::pound_sourceLocation)) {
+ ParserStatus Status = parseLineDirective(false);
+ BraceItemsStatus |= Status;
+ NeedParseErrorRecovery = Status.isError();
+ } else if (isStartOfDecl()) {
+ SmallVector<Decl*, 8> TmpDecls;
ParserResult<Decl> DeclResult =
parseDecl(IsTopLevel ? PD_AllowTopLevel : PD_Default,
[&](Decl *D) {TmpDecls.push_back(D);});
@@ -307,51 +340,7 @@
}
}
Result = DeclResult.getPtrOrNull();
-
- for (Decl *D : TmpDecls)
- Entries.push_back(D);
- TmpDecls.clear();
- } else if (Tok.is(tok::pound_if)) {
- auto IfConfigResult = parseIfConfig(
- [&](SmallVectorImpl<ASTNode> &Elements, bool IsActive) {
- parseBraceItems(Elements, Kind, IsActive
- ? BraceItemListKind::ActiveConditionalBlock
- : BraceItemListKind::InactiveConditionalBlock);
- });
-
- if (IfConfigResult.isParseError()) {
- NeedParseErrorRecovery = true;
- continue;
- }
-
- Result = IfConfigResult.get();
-
- if (!Result) {
- NeedParseErrorRecovery = true;
- continue;
- }
-
- // Add the #if block itself
- Entries.push_back(Result);
-
- IfConfigDecl *ICD = cast<IfConfigDecl>(Result.get<Decl*>());
- for (auto &Entry : ICD->getActiveClauseElements()) {
- if (Entry.is<Decl*>() && isa<IfConfigDecl>(Entry.get<Decl*>()))
- // Don't hoist nested '#if'.
- continue;
- Entries.push_back(Entry);
- if (Entry.is<Decl*>()) {
- Entry.get<Decl*>()->setEscapedFromIfConfig(true);
- }
- }
- } else if (Tok.is(tok::pound_line)) {
- ParserStatus Status = parseLineDirective(true);
- BraceItemsStatus |= Status;
- NeedParseErrorRecovery = Status.isError();
- } else if (Tok.is(tok::pound_sourceLocation)) {
- ParserStatus Status = parseLineDirective(false);
- BraceItemsStatus |= Status;
- NeedParseErrorRecovery = Status.isError();
+ Entries.append(TmpDecls.begin(), TmpDecls.end());
} else if (IsTopLevel) {
// If this is a statement or expression at the top level of the module,
// Parse it as a child of a TopLevelCodeDecl.
diff --git a/lib/Syntax/Status.md b/lib/Syntax/Status.md
index 8a66126..e5cffeb 100644
--- a/lib/Syntax/Status.md
+++ b/lib/Syntax/Status.md
@@ -24,31 +24,29 @@
* ForceTryExpr
* OptionalTryExpr
* ClosureExpr
+ * FunctionCallExpr
+ * SubscriptExpr
+ * PostfixUnaryExpr
+ * ForcedValueExpr
+ * SuperRefExpr
+ * ImplicitMemberExpr
### In-progress (UnknownExpr):
* InterpolatedStringLiteralExpr
* ObjectLiteralExpr
* MagicIdentifierLiteralExpr
- * CallExpr
- * UnresolvedDotExpr
* InOutExpr
* KeyPathExpr
* KeyPathDotExpr
* EditorPlaceholderExpr
### Not-started (UnknownExpr):
- * SuperRefExpr
* UnresolvedSpecializeExpr
* DotSelfExpr
- * SubscriptExpr
* KeyPathApplicationExpr
* CaptureListExpr
* AutoClosureExpr
* DynamicTypeExpr
- * BindOptionalExpr
- * OptionalEvaluationExpr
- * ForceValueExpr
- * PostfixUnaryExpr
* ForcedCheckedCastExpr
* ConditionalCheckedCastExpr
* IsExpr
@@ -98,12 +96,12 @@
* ContinueStmt
* FallthroughStmt
* ThrowStmt
-
-### Not-started (UnknownStmt):
* IfStmt
* GuardStmt
* WhileStmt
- * ForEachStmt
+ * ForInStmt
+
+### Not-started (UnknownStmt):
* SwitchStmt
## Pattern
diff --git a/lib/Syntax/SyntaxParsingContext.cpp b/lib/Syntax/SyntaxParsingContext.cpp
index 4ad4542..4b7dfb8 100644
--- a/lib/Syntax/SyntaxParsingContext.cpp
+++ b/lib/Syntax/SyntaxParsingContext.cpp
@@ -110,13 +110,20 @@
return;
switch (Kind) {
+ case SyntaxKind::SuperRefExpr:
case SyntaxKind::MemberAccessExpr:
+ case SyntaxKind::ImplicitMemberExpr:
+ case SyntaxKind::OptionalChainingExpr:
+ case SyntaxKind::ForcedValueExpr:
+ case SyntaxKind::PostfixUnaryExpr:
case SyntaxKind::TernaryExpr: {
auto Pair = SyntaxFactory::countChildren(Kind);
assert(Pair.first == Pair.second);
createNodeInPlace(Kind, Pair.first);
break;
}
+ case SyntaxKind::FunctionCallExpr:
+ case SyntaxKind::SubscriptExpr:
case SyntaxKind::ExprList: {
createNodeInPlace(Kind, Parts.size());
break;
diff --git a/test/Parse/ConditionalCompilation/pound-if-top-level-3.swift b/test/Parse/ConditionalCompilation/pound-if-top-level-3.swift
index ca359fb..6bb2046 100644
--- a/test/Parse/ConditionalCompilation/pound-if-top-level-3.swift
+++ b/test/Parse/ConditionalCompilation/pound-if-top-level-3.swift
@@ -2,5 +2,6 @@
#if arch(x86_64)
// expected-error@+2{{expected '{' in protocol type}}
-// expected-error@+1{{expected #else or #endif at end of conditional compilation block}}
+// expected-error@+1{{extraneous '}' at top level}}
public protocol CS}
+// expected-error@+1{{expected #else or #endif at end of conditional compilation block}}
diff --git a/test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds b/test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds
index 394bf76..bc7bac7 100644
--- a/test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds
+++ b/test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds
@@ -18,28 +18,28 @@
func bar4<FunctionSignature><ParameterClause>(<FunctionParameter>_ a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause></FunctionSignature><CodeBlock>{ <ReturnStmt>return <IntegerLiteralExpr>1 </IntegerLiteralExpr></ReturnStmt>}</CodeBlock></FunctionDecl><FunctionDecl>
func foo<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<VariableDecl>
var <PatternBinding><IdentifierPattern>a </IdentifierPattern><InitializerClause>= <StringLiteralExpr>/*comment*/"ab\(x)c"</StringLiteralExpr></InitializerClause></PatternBinding></VariableDecl><VariableDecl>/*comment*/
- var <PatternBinding><IdentifierPattern>b </IdentifierPattern><InitializerClause>= <PrefixOperatorExpr>/*comment*/+<IntegerLiteralExpr>2</IntegerLiteralExpr></PrefixOperatorExpr></InitializerClause></PatternBinding></VariableDecl><IdentifierExpr>/*comment*/
- bar</IdentifierExpr>(<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)<IdentifierExpr>
- bar</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>+<IntegerLiteralExpr>10</IntegerLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)<IdentifierExpr>
- bar</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>-<IntegerLiteralExpr>10</IntegerLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)<IdentifierExpr>
- bar1</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>-<FloatLiteralExpr>1.1</FloatLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)<IdentifierExpr>
- bar1</IdentifierExpr>(<FunctionCallArgument><FloatLiteralExpr>1.1</FloatLiteralExpr></FunctionCallArgument>)<VariableDecl>
- var <PatternBinding><IdentifierPattern>f </IdentifierPattern><InitializerClause>= <PrefixOperatorExpr>/*comments*/+<FloatLiteralExpr>0.1</FloatLiteralExpr></PrefixOperatorExpr></InitializerClause></PatternBinding></VariableDecl><IdentifierExpr>/*comments*/
- foo</IdentifierExpr>()
+ var <PatternBinding><IdentifierPattern>b </IdentifierPattern><InitializerClause>= <PrefixOperatorExpr>/*comment*/+<IntegerLiteralExpr>2</IntegerLiteralExpr></PrefixOperatorExpr></InitializerClause></PatternBinding></VariableDecl><FunctionCallExpr><IdentifierExpr>/*comment*/
+ bar</IdentifierExpr>(<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
+ bar</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>+<IntegerLiteralExpr>10</IntegerLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
+ bar</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>-<IntegerLiteralExpr>10</IntegerLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
+ bar1</IdentifierExpr>(<FunctionCallArgument><PrefixOperatorExpr>-<FloatLiteralExpr>1.1</FloatLiteralExpr></PrefixOperatorExpr></FunctionCallArgument>)</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
+ bar1</IdentifierExpr>(<FunctionCallArgument><FloatLiteralExpr>1.1</FloatLiteralExpr></FunctionCallArgument>)</FunctionCallExpr><VariableDecl>
+ var <PatternBinding><IdentifierPattern>f </IdentifierPattern><InitializerClause>= <PrefixOperatorExpr>/*comments*/+<FloatLiteralExpr>0.1</FloatLiteralExpr></PrefixOperatorExpr></InitializerClause></PatternBinding></VariableDecl><FunctionCallExpr><IdentifierExpr>/*comments*/
+ foo</IdentifierExpr>()</FunctionCallExpr>
}</CodeBlock></FunctionDecl><FunctionDecl>
func foo1<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>b:<IntegerLiteralExpr>2</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>c:<IntegerLiteralExpr>2</IntegerLiteralExpr></FunctionCallArgument>)</SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a:<SequenceExpr><IntegerLiteralExpr>1 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>1</IntegerLiteralExpr></SequenceExpr>, </FunctionCallArgument><FunctionCallArgument>b:<SequenceExpr><IntegerLiteralExpr>2 </IntegerLiteralExpr><BinaryOperatorExpr>* </BinaryOperatorExpr><IntegerLiteralExpr>2 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>2</IntegerLiteralExpr></SequenceExpr>, </FunctionCallArgument><FunctionCallArgument>c:<SequenceExpr><IntegerLiteralExpr>2 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>2</IntegerLiteralExpr></SequenceExpr></FunctionCallArgument>)</SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a : <IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a: <IntegerLiteralExpr>1</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>b: <IntegerLiteralExpr>2</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>c: <IntegerLiteralExpr>3</IntegerLiteralExpr></FunctionCallArgument>), </FunctionCallArgument><FunctionCallArgument>b: <IntegerLiteralExpr>2</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>c: <IntegerLiteralExpr>3</IntegerLiteralExpr></FunctionCallArgument>)</SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a : <IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a: <IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a: <IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallArgument>)</FunctionCallArgument>)</SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>bar4</IdentifierExpr>(<FunctionCallArgument><IdentifierExpr>bar4</IdentifierExpr>(<FunctionCallArgument><IdentifierExpr>bar4</IdentifierExpr>(<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallArgument>)</FunctionCallArgument>)</SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>b:<IntegerLiteralExpr>2</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>c:<IntegerLiteralExpr>2</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a:<SequenceExpr><IntegerLiteralExpr>1 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>1</IntegerLiteralExpr></SequenceExpr>, </FunctionCallArgument><FunctionCallArgument>b:<SequenceExpr><IntegerLiteralExpr>2 </IntegerLiteralExpr><BinaryOperatorExpr>* </BinaryOperatorExpr><IntegerLiteralExpr>2 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>2</IntegerLiteralExpr></SequenceExpr>, </FunctionCallArgument><FunctionCallArgument>c:<SequenceExpr><IntegerLiteralExpr>2 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>2</IntegerLiteralExpr></SequenceExpr></FunctionCallArgument>)</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a : <FunctionCallExpr><IdentifierExpr>bar2</IdentifierExpr>(<FunctionCallArgument>a: <IntegerLiteralExpr>1</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>b: <IntegerLiteralExpr>2</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>c: <IntegerLiteralExpr>3</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </FunctionCallArgument><FunctionCallArgument>b: <IntegerLiteralExpr>2</IntegerLiteralExpr>, </FunctionCallArgument><FunctionCallArgument>c: <IntegerLiteralExpr>3</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a : <FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a: <FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a: <IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></FunctionCallArgument>)</FunctionCallExpr></FunctionCallArgument>)</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><IdentifierExpr>bar4</IdentifierExpr>(<FunctionCallArgument><FunctionCallExpr><IdentifierExpr>bar4</IdentifierExpr>(<FunctionCallArgument><FunctionCallExpr><IdentifierExpr>bar4</IdentifierExpr>(<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></FunctionCallArgument>)</FunctionCallExpr></FunctionCallArgument>)</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><DictionaryExpr>[:]</DictionaryExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ArrayExpr>[<ArrayElement><IntegerLiteralExpr>1</IntegerLiteralExpr>, </ArrayElement><ArrayElement><IntegerLiteralExpr>2</IntegerLiteralExpr>, </ArrayElement><ArrayElement><IntegerLiteralExpr>3</IntegerLiteralExpr>, </ArrayElement><ArrayElement><IntegerLiteralExpr>4</IntegerLiteralExpr></ArrayElement>]</ArrayExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><DictionaryExpr>[<DictionaryElement><IntegerLiteralExpr>1</IntegerLiteralExpr>:<IntegerLiteralExpr>1</IntegerLiteralExpr>, </DictionaryElement><DictionaryElement><IntegerLiteralExpr>2</IntegerLiteralExpr>:<IntegerLiteralExpr>2</IntegerLiteralExpr>, </DictionaryElement><DictionaryElement><IntegerLiteralExpr>3</IntegerLiteralExpr>:<IntegerLiteralExpr>3</IntegerLiteralExpr>, </DictionaryElement><DictionaryElement><IntegerLiteralExpr>4</IntegerLiteralExpr>:<IntegerLiteralExpr>4</IntegerLiteralExpr></DictionaryElement>]</DictionaryExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ArrayExpr>[<ArrayElement><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>), </ArrayElement><ArrayElement><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>), </ArrayElement><ArrayElement><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>), </ArrayElement><ArrayElement><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</ArrayElement>]</ArrayExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><DictionaryExpr>[<DictionaryElement><StringLiteralExpr>"a"</StringLiteralExpr>: <IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>), </DictionaryElement><DictionaryElement><StringLiteralExpr>"b"</StringLiteralExpr>: <IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>), </DictionaryElement><DictionaryElement><StringLiteralExpr>"c"</StringLiteralExpr>: <IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>), </DictionaryElement><DictionaryElement><StringLiteralExpr>"d"</StringLiteralExpr>: <IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</DictionaryElement>]</DictionaryExpr></SequenceExpr><IdentifierExpr>
- foo</IdentifierExpr>(<FunctionCallArgument><NilLiteralExpr>nil</NilLiteralExpr>, </FunctionCallArgument><FunctionCallArgument><NilLiteralExpr>nil</NilLiteralExpr>, </FunctionCallArgument><FunctionCallArgument><NilLiteralExpr>nil</NilLiteralExpr></FunctionCallArgument>)
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ArrayExpr>[<ArrayElement><FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </ArrayElement><ArrayElement><FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </ArrayElement><ArrayElement><FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </ArrayElement><ArrayElement><FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></ArrayElement>]</ArrayExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><DictionaryExpr>[<DictionaryElement><StringLiteralExpr>"a"</StringLiteralExpr>: <FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </DictionaryElement><DictionaryElement><StringLiteralExpr>"b"</StringLiteralExpr>: <FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </DictionaryElement><DictionaryElement><StringLiteralExpr>"c"</StringLiteralExpr>: <FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>, </DictionaryElement><DictionaryElement><StringLiteralExpr>"d"</StringLiteralExpr>: <FunctionCallExpr><IdentifierExpr>bar3</IdentifierExpr>(<FunctionCallArgument>a:<IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></DictionaryElement>]</DictionaryExpr></SequenceExpr><FunctionCallExpr><IdentifierExpr>
+ foo</IdentifierExpr>(<FunctionCallArgument><NilLiteralExpr>nil</NilLiteralExpr>, </FunctionCallArgument><FunctionCallArgument><NilLiteralExpr>nil</NilLiteralExpr>, </FunctionCallArgument><FunctionCallArgument><NilLiteralExpr>nil</NilLiteralExpr></FunctionCallArgument>)</FunctionCallExpr>
}</CodeBlock></FunctionDecl><FunctionDecl>
func boolAnd<FunctionSignature><ParameterClause>() </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Bool </SimpleTypeIdentifier></ReturnClause></FunctionSignature><CodeBlock>{ <ReturnStmt>return <SequenceExpr><BooleanLiteralExpr>true </BooleanLiteralExpr><BinaryOperatorExpr>&& </BinaryOperatorExpr><BooleanLiteralExpr>false </BooleanLiteralExpr></SequenceExpr></ReturnStmt>}</CodeBlock></FunctionDecl><FunctionDecl>
func boolOr<FunctionSignature><ParameterClause>() </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Bool </SimpleTypeIdentifier></ReturnClause></FunctionSignature><CodeBlock>{ <ReturnStmt>return <SequenceExpr><BooleanLiteralExpr>true </BooleanLiteralExpr><BinaryOperatorExpr>|| </BinaryOperatorExpr><BooleanLiteralExpr>false </BooleanLiteralExpr></SequenceExpr></ReturnStmt>}</CodeBlock></FunctionDecl><FunctionDecl>
@@ -57,13 +57,28 @@
}</CodeBlock></FunctionDecl><FunctionDecl>
func foo3<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<SequenceExpr><DiscardAssignmentExpr>
- _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ArrayExpr>[<ArrayElement><TypeExpr><SimpleTypeIdentifier>Any</SimpleTypeIdentifier></TypeExpr></ArrayElement>]</ArrayExpr>()</SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><ArrayExpr>[<ArrayElement><TypeExpr><SimpleTypeIdentifier>Any</SimpleTypeIdentifier></TypeExpr></ArrayElement>]</ArrayExpr>()</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><MemberAccessExpr><MemberAccessExpr><IdentifierExpr>a</IdentifierExpr>.a</MemberAccessExpr>.a</MemberAccessExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><MemberAccessExpr><IdentifierExpr>a</IdentifierExpr>.b</MemberAccessExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><MemberAccessExpr><IntegerLiteralExpr>1</IntegerLiteralExpr>.a</MemberAccessExpr></SequenceExpr><MemberAccessExpr><MemberAccessExpr><MemberAccessExpr><TupleExpr>
(<TupleElement><SequenceExpr><IntegerLiteralExpr>1 </IntegerLiteralExpr><BinaryOperatorExpr>+ </BinaryOperatorExpr><IntegerLiteralExpr>1</IntegerLiteralExpr></SequenceExpr></TupleElement>)</TupleExpr>.a</MemberAccessExpr>.b</MemberAccessExpr>.foo</MemberAccessExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>a </IdentifierExpr><AsExpr>as <SimpleTypeIdentifier>Bool </SimpleTypeIdentifier></AsExpr><BinaryOperatorExpr>|| </BinaryOperatorExpr><IdentifierExpr>a </IdentifierExpr><AsExpr>as! <SimpleTypeIdentifier>Bool </SimpleTypeIdentifier></AsExpr><BinaryOperatorExpr>|| </BinaryOperatorExpr><IdentifierExpr>a </IdentifierExpr><AsExpr>as? <SimpleTypeIdentifier>Bool</SimpleTypeIdentifier></AsExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
_ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><IdentifierExpr>a </IdentifierExpr><IsExpr>is <SimpleTypeIdentifier>Bool</SimpleTypeIdentifier></IsExpr></SequenceExpr>
+ }</CodeBlock></FunctionDecl><FunctionDecl>
+
+ func superExpr<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><MemberAccessExpr><SuperRefExpr>super</SuperRefExpr>.foo</MemberAccessExpr></SequenceExpr><FunctionCallExpr><MemberAccessExpr><SuperRefExpr>
+ super</SuperRefExpr>.bar</MemberAccessExpr>()</FunctionCallExpr><SequenceExpr><SubscriptExpr><SuperRefExpr>
+ super</SuperRefExpr>[<FunctionCallArgument><IntegerLiteralExpr>12</IntegerLiteralExpr></FunctionCallArgument>] </SubscriptExpr><AssignmentExpr>= </AssignmentExpr><IntegerLiteralExpr>1</IntegerLiteralExpr></SequenceExpr><FunctionCallExpr><MemberAccessExpr><SuperRefExpr>
+ super</SuperRefExpr>.init</MemberAccessExpr>()</FunctionCallExpr>
+ }</CodeBlock></FunctionDecl><FunctionDecl>
+
+ func implictMember<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ImplicitMemberExpr>.foo</ImplicitMemberExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><ImplicitMemberExpr>.foo</ImplicitMemberExpr>(<FunctionCallArgument>x: <IntegerLiteralExpr>12</IntegerLiteralExpr></FunctionCallArgument>)</FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><FunctionCallExpr><ImplicitMemberExpr>.foo </ImplicitMemberExpr><ClosureExpr>{ <IntegerLiteralExpr>12 </IntegerLiteralExpr>}</ClosureExpr></FunctionCallExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><SubscriptExpr><ImplicitMemberExpr>.foo</ImplicitMemberExpr>[<FunctionCallArgument><IntegerLiteralExpr>12</IntegerLiteralExpr></FunctionCallArgument>]</SubscriptExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><MemberAccessExpr><ImplicitMemberExpr>.foo</ImplicitMemberExpr>.bar</MemberAccessExpr></SequenceExpr>
}</CodeBlock></FunctionDecl>
}</MemberDeclBlock></ClassDecl>
@@ -158,38 +173,53 @@
#if <IdentifierExpr>blah</IdentifierExpr><FunctionDecl>
func tryfoo<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<TryExpr>
- try <IdentifierExpr>foo</IdentifierExpr>()</TryExpr><TryExpr>
- try! <IdentifierExpr>foo</IdentifierExpr>()</TryExpr><TryExpr>
- try? <IdentifierExpr>foo</IdentifierExpr>()</TryExpr><TryExpr>
- try! <MemberAccessExpr><IdentifierExpr>foo</IdentifierExpr>().bar</MemberAccessExpr>().foo().bar()</TryExpr>
+ try <FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr></TryExpr><TryExpr>
+ try! <FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr></TryExpr><TryExpr>
+ try? <FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr></TryExpr><TryExpr>
+ try! <FunctionCallExpr><MemberAccessExpr><FunctionCallExpr><MemberAccessExpr><FunctionCallExpr><MemberAccessExpr><FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr>.bar</MemberAccessExpr>()</FunctionCallExpr>.foo</MemberAccessExpr>()</FunctionCallExpr>.bar</MemberAccessExpr>()</FunctionCallExpr></TryExpr>
}</CodeBlock></FunctionDecl><ElseDirectiveClause>
#else<FunctionDecl>
-func closure<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<ClosureExpr>
- {<ClosureSignature><ClosureCaptureSignature>[<ClosureCaptureItem>weak <IdentifierExpr>a</IdentifierExpr>,</ClosureCaptureItem><ClosureCaptureItem>
+func closure<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{<ClosureSignature><ClosureCaptureSignature>[<ClosureCaptureItem>weak <IdentifierExpr>a</IdentifierExpr>,</ClosureCaptureItem><ClosureCaptureItem>
unowned(safe) self,</ClosureCaptureItem><ClosureCaptureItem>
b = <IntegerLiteralExpr>3</IntegerLiteralExpr>,</ClosureCaptureItem><ClosureCaptureItem>
- unowned(unsafe) c = <MemberAccessExpr><IdentifierExpr>foo</IdentifierExpr>().bar</MemberAccessExpr></ClosureCaptureItem>] </ClosureCaptureSignature>in</ClosureSignature>
- }</ClosureExpr><ClosureExpr>
- {<ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature>in </ClosureSignature>}</ClosureExpr><ClosureExpr>
+ unowned(unsafe) c = <MemberAccessExpr><FunctionCallExpr><IdentifierExpr>foo</IdentifierExpr>()</FunctionCallExpr>.bar</MemberAccessExpr></ClosureCaptureItem>] </ClosureCaptureSignature>in</ClosureSignature>
+ }</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{<ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature>in </ClosureSignature>}</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
- { <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ClosureParam>a, </ClosureParam><ClosureParam>b, </ClosureParam><ClosureParam>_ </ClosureParam><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ClosureParam>a, </ClosureParam><ClosureParam>b, </ClosureParam><ClosureParam>_ </ClosureParam><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
return <IntegerLiteralExpr>2</IntegerLiteralExpr></ReturnStmt>
- }</ClosureExpr><ClosureExpr>
- { <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ParameterClause>(<FunctionParameter>a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier>, </FunctionParameter><FunctionParameter>b: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier>, </FunctionParameter><FunctionParameter>_: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
+ }</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ParameterClause>(<FunctionParameter>a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier>, </FunctionParameter><FunctionParameter>b: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier>, </FunctionParameter><FunctionParameter>_: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
return <IntegerLiteralExpr>2</IntegerLiteralExpr></ReturnStmt>
- }</ClosureExpr><ClosureExpr>
- { <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ClosureParam>a, </ClosureParam><ClosureParam>b, </ClosureParam><ClosureParam>_ </ClosureParam>throws <ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
+ }</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ClosureParam>a, </ClosureParam><ClosureParam>b, </ClosureParam><ClosureParam>_ </ClosureParam>throws <ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
return <IntegerLiteralExpr>2</IntegerLiteralExpr></ReturnStmt>
- }</ClosureExpr><ClosureExpr>
- { <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ParameterClause>(<FunctionParameter>a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier>, </FunctionParameter><FunctionParameter>_ b: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause>throws <ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
+ }</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <ClosureSignature><ClosureCaptureSignature>[] </ClosureCaptureSignature><ParameterClause>(<FunctionParameter>a: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier>, </FunctionParameter><FunctionParameter>_ b: <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></FunctionParameter>) </ParameterClause>throws <ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause>in</ClosureSignature><ReturnStmt>
return <IntegerLiteralExpr>2</IntegerLiteralExpr></ReturnStmt>
- }</ClosureExpr><ClosureExpr>
- { <ClosureSignature><ClosureParam>a, </ClosureParam><ClosureParam>b </ClosureParam>in </ClosureSignature>}</ClosureExpr><ClosureExpr>
- {}</ClosureExpr><ClosureExpr>
- { <ClosureSignature><ClosureParam>s1, </ClosureParam><ClosureParam>s2 </ClosureParam>in </ClosureSignature><SequenceExpr><IdentifierExpr>s1 </IdentifierExpr><BinaryOperatorExpr>> </BinaryOperatorExpr><IdentifierExpr>s2 </IdentifierExpr></SequenceExpr>}</ClosureExpr><ClosureExpr>
- { <SequenceExpr>$0 <BinaryOperatorExpr>> </BinaryOperatorExpr>$1 </SequenceExpr>}</ClosureExpr>
+ }</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <ClosureSignature><ClosureParam>a, </ClosureParam><ClosureParam>b </ClosureParam>in </ClosureSignature>}</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{}</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <ClosureSignature><ClosureParam>s1, </ClosureParam><ClosureParam>s2 </ClosureParam>in </ClosureSignature><SequenceExpr><IdentifierExpr>s1 </IdentifierExpr><BinaryOperatorExpr>> </BinaryOperatorExpr><IdentifierExpr>s2 </IdentifierExpr></SequenceExpr>}</ClosureExpr></SequenceExpr><SequenceExpr><DiscardAssignmentExpr>
+ _ </DiscardAssignmentExpr><AssignmentExpr>= </AssignmentExpr><ClosureExpr>{ <SequenceExpr>$0 <BinaryOperatorExpr>> </BinaryOperatorExpr>$1 </SequenceExpr>}</ClosureExpr></SequenceExpr>
}</CodeBlock></FunctionDecl></ElseDirectiveClause>
-#endif</IfConfigDecl><IfConfigDecl>
+#endif</IfConfigDecl><FunctionDecl>
+
+func postfix<FunctionSignature><ParameterClause>() </ParameterClause></FunctionSignature><CodeBlock>{<FunctionCallExpr><IdentifierExpr>
+ foo</IdentifierExpr>()</FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
+ foo</IdentifierExpr>() <ClosureExpr>{}</ClosureExpr></FunctionCallExpr><FunctionCallExpr><IdentifierExpr>
+ foo </IdentifierExpr><ClosureExpr>{}</ClosureExpr></FunctionCallExpr><FunctionCallExpr><MemberAccessExpr><IdentifierExpr>
+ foo</IdentifierExpr>.bar</MemberAccessExpr>()</FunctionCallExpr><FunctionCallExpr><MemberAccessExpr><IdentifierExpr>
+ foo</IdentifierExpr>.bar</MemberAccessExpr>() <ClosureExpr>{}</ClosureExpr></FunctionCallExpr><FunctionCallExpr><MemberAccessExpr><IdentifierExpr>
+ foo</IdentifierExpr>.bar </MemberAccessExpr><ClosureExpr>{}</ClosureExpr></FunctionCallExpr><SubscriptExpr><IdentifierExpr>
+ foo</IdentifierExpr>[]</SubscriptExpr><SubscriptExpr><IdentifierExpr>
+ foo</IdentifierExpr>[<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>]</SubscriptExpr><SubscriptExpr><IdentifierExpr>
+ foo</IdentifierExpr>[] <ClosureExpr>{}</ClosureExpr></SubscriptExpr><SubscriptExpr><IdentifierExpr>
+ foo</IdentifierExpr>[<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>] <ClosureExpr>{}</ClosureExpr></SubscriptExpr><SubscriptExpr><SubscriptExpr><IdentifierExpr>
+ foo</IdentifierExpr>[<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>]</SubscriptExpr>[<FunctionCallArgument><IntegerLiteralExpr>2</IntegerLiteralExpr>,</FunctionCallArgument><FunctionCallArgument>x:<IntegerLiteralExpr>3</IntegerLiteralExpr></FunctionCallArgument>]</SubscriptExpr><FunctionCallExpr><ForcedValueExpr><MemberAccessExpr><PostfixUnaryExpr><OptionalChainingExpr><IdentifierExpr>
+ foo</IdentifierExpr>?</OptionalChainingExpr>++</PostfixUnaryExpr>.bar</MemberAccessExpr>!</ForcedValueExpr>(<FunctionCallArgument><IdentifierExpr>baz</IdentifierExpr></FunctionCallArgument>)</FunctionCallExpr>
+}</CodeBlock></FunctionDecl><IfConfigDecl>
#if <IdentifierExpr>blah</IdentifierExpr><ElseDirectiveClause>
#else</ElseDirectiveClause>
@@ -230,10 +260,10 @@
case <ValueBindingPattern>let <ExpressionPattern><TupleExpr>(<TupleElement><UnresolvedPatternExpr><IdentifierPattern>a</IdentifierPattern></UnresolvedPatternExpr>, </TupleElement><TupleElement><UnresolvedPatternExpr><IdentifierPattern>b</IdentifierPattern></UnresolvedPatternExpr></TupleElement>)</TupleExpr></ExpressionPattern></ValueBindingPattern>: <BreakStmt>break</BreakStmt>
case <ExpressionPattern><TupleExpr>(<TupleElement><UnresolvedPatternExpr><ValueBindingPattern>let <IdentifierPattern>a</IdentifierPattern></ValueBindingPattern></UnresolvedPatternExpr>, </TupleElement><TupleElement><UnresolvedPatternExpr><ValueBindingPattern>var <IdentifierPattern>b</IdentifierPattern></ValueBindingPattern></UnresolvedPatternExpr></TupleElement>)</TupleExpr></ExpressionPattern>: <BreakStmt>break</BreakStmt>
case <IsTypePattern>is <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></IsTypePattern>: <BreakStmt>break</BreakStmt>
- case <ValueBindingPattern>let <ExpressionPattern>.bar(<FunctionCallArgument><UnresolvedPatternExpr><IdentifierPattern>x</IdentifierPattern></UnresolvedPatternExpr></FunctionCallArgument>)</ExpressionPattern></ValueBindingPattern>: <BreakStmt>break</BreakStmt>
+ case <ValueBindingPattern>let <ExpressionPattern><FunctionCallExpr><ImplicitMemberExpr>.bar</ImplicitMemberExpr>(<FunctionCallArgument><UnresolvedPatternExpr><IdentifierPattern>x</IdentifierPattern></UnresolvedPatternExpr></FunctionCallArgument>)</FunctionCallExpr></ExpressionPattern></ValueBindingPattern>: <BreakStmt>break</BreakStmt>
case <ExpressionPattern><MemberAccessExpr><IdentifierExpr>MyEnum</IdentifierExpr>.foo</MemberAccessExpr></ExpressionPattern>: <BreakStmt>break</BreakStmt>
case <ValueBindingPattern>let <ExpressionPattern><SequenceExpr><UnresolvedPatternExpr><IdentifierPattern>a </IdentifierPattern></UnresolvedPatternExpr><AsExpr>as <SimpleTypeIdentifier>Int</SimpleTypeIdentifier></AsExpr></SequenceExpr></ExpressionPattern></ValueBindingPattern>: <BreakStmt>break</BreakStmt>
- case <ValueBindingPattern>let <ExpressionPattern><UnresolvedPatternExpr><IdentifierPattern>a</IdentifierPattern></UnresolvedPatternExpr>?</ExpressionPattern></ValueBindingPattern>: <BreakStmt>break</BreakStmt>
+ case <ValueBindingPattern>let <ExpressionPattern><OptionalChainingExpr><UnresolvedPatternExpr><IdentifierPattern>a</IdentifierPattern></UnresolvedPatternExpr>?</OptionalChainingExpr></ExpressionPattern></ValueBindingPattern>: <BreakStmt>break</BreakStmt>
}
}</CodeBlock></DoStmt><FunctionDecl>
@@ -259,7 +289,7 @@
for <IdentifierPattern>a </IdentifierPattern>in <IdentifierExpr>b </IdentifierExpr><CodeBlock>{<DeferStmt>
defer <CodeBlock>{ <TupleExpr>() </TupleExpr>}</CodeBlock></DeferStmt><IfStmt>
if <ConditionElement><IdentifierExpr>c </IdentifierExpr></ConditionElement><CodeBlock>{<ThrowStmt>
- throw <IdentifierExpr>MyError</IdentifierExpr>()</ThrowStmt><ContinueStmt>
+ throw <FunctionCallExpr><IdentifierExpr>MyError</IdentifierExpr>()</FunctionCallExpr></ThrowStmt><ContinueStmt>
continue</ContinueStmt>
} </CodeBlock>else <CodeBlock>{<ContinueStmt>
continue LABEL</ContinueStmt>
diff --git a/test/Syntax/round_trip_parse_gen.swift b/test/Syntax/round_trip_parse_gen.swift
index c8734c3..c6f074a 100644
--- a/test/Syntax/round_trip_parse_gen.swift
+++ b/test/Syntax/round_trip_parse_gen.swift
@@ -65,6 +65,21 @@
_ = a as Bool || a as! Bool || a as? Bool
_ = a is Bool
}
+
+ func superExpr() {
+ _ = super.foo
+ super.bar()
+ super[12] = 1
+ super.init()
+ }
+
+ func implictMember() {
+ _ = .foo
+ _ = .foo(x: 12)
+ _ = .foo { 12 }
+ _ = .foo[12]
+ _ = .foo.bar
+ }
}
#endif
@@ -165,32 +180,47 @@
}
#else
func closure() {
- {[weak a,
+ _ = {[weak a,
unowned(safe) self,
b = 3,
unowned(unsafe) c = foo().bar] in
}
- {[] in }
+ _ = {[] in }
- { [] a, b, _ -> Int in
+ _ = { [] a, b, _ -> Int in
return 2
}
- { [] (a: Int, b: Int, _: Int) -> Int in
+ _ = { [] (a: Int, b: Int, _: Int) -> Int in
return 2
}
- { [] a, b, _ throws -> Int in
+ _ = { [] a, b, _ throws -> Int in
return 2
}
- { [] (a: Int, _ b: Int) throws -> Int in
+ _ = { [] (a: Int, _ b: Int) throws -> Int in
return 2
}
- { a, b in }
- {}
- { s1, s2 in s1 > s2 }
- { $0 > $1 }
+ _ = { a, b in }
+ _ = {}
+ _ = { s1, s2 in s1 > s2 }
+ _ = { $0 > $1 }
}
#endif
+func postfix() {
+ foo()
+ foo() {}
+ foo {}
+ foo.bar()
+ foo.bar() {}
+ foo.bar {}
+ foo[]
+ foo[1]
+ foo[] {}
+ foo[1] {}
+ foo[1][2,x:3]
+ foo?++.bar!(baz)
+}
+
#if blah
#else
#endif
diff --git a/unittests/Syntax/ExprSyntaxTests.cpp b/unittests/Syntax/ExprSyntaxTests.cpp
index 26d9710..033e140 100644
--- a/unittests/Syntax/ExprSyntaxTests.cpp
+++ b/unittests/Syntax/ExprSyntaxTests.cpp
@@ -401,7 +401,7 @@
auto RightParen = SyntaxFactory::makeRightParenToken({}, {});
auto Call = SyntaxFactory::makeFunctionCallExpr(SymbolicRef, LeftParen,
- ArgList, RightParen);
+ ArgList, RightParen, None);
{
auto GottenExpression1 = Call.getCalledExpression();
@@ -413,8 +413,8 @@
ASSERT_EQ(OS.str().str(), "foo");
}
- ASSERT_EQ(LeftParen.getRaw(), Call.getLeftParen().getRaw());
- ASSERT_EQ(RightParen.getRaw(), Call.getRightParen().getRaw());
+ ASSERT_EQ(LeftParen.getRaw(), Call.getLeftParen()->getRaw());
+ ASSERT_EQ(RightParen.getRaw(), Call.getRightParen()->getRaw());
{
auto GottenArgs1 = Call.getArgumentList();
@@ -436,7 +436,7 @@
{
auto Call = SyntaxFactory::makeFunctionCallExpr(SymbolicRef, LeftParen,
- ArgList, RightParen);
+ ArgList, RightParen, None);
llvm::SmallString<64> Scratch;
llvm::raw_svector_ostream OS(Scratch);
Call.print(OS);
diff --git a/unittests/Syntax/UnknownSyntaxTests.cpp b/unittests/Syntax/UnknownSyntaxTests.cpp
index 7153159..c6e36bb 100644
--- a/unittests/Syntax/UnknownSyntaxTests.cpp
+++ b/unittests/Syntax/UnknownSyntaxTests.cpp
@@ -41,7 +41,7 @@
auto Args = SyntaxFactory::makeFunctionCallArgumentList({ Arg });
return SyntaxFactory::makeFunctionCallExpr(getCannedSymbolicRef(), LParen,
- Args, RParen);
+ Args, RParen, None);
}
TEST(UnknownSyntaxTests, UnknownSyntaxMakeAPIs) {
@@ -83,7 +83,7 @@
// RawSyntax layout but with the UnknownExpr Kind.;
auto Unknown = make<UnknownExprSyntax>(Call.getRaw());
- ASSERT_EQ(Unknown.getNumChildren(), size_t(2));
+ ASSERT_EQ(Unknown.getNumChildren(), size_t(3));
// Get the second child from the unknown call, which is the argument list.
// This should print the same as the known one: "elements: 1"
@@ -113,7 +113,7 @@
// RawSyntax layout but with the Unknown Kind.
auto Unknown = make<UnknownSyntax>(Call.getRaw());
- ASSERT_EQ(Unknown.getNumChildren(), size_t(2));
+ ASSERT_EQ(Unknown.getNumChildren(), size_t(3));
// Get the second child from the unknown call, which is the argument list.
// This should print the same as the known one: "elements: 1"
@@ -142,7 +142,7 @@
auto CallWithKnownExpr = SyntaxFactory::makeFunctionCallExpr(SymbolicRef,
LParen,
EmptyArgs,
- RParen);
+ RParen, None);
CallWithKnownExpr.print(KnownOS);
// Let's make a function call expression where the called expression is
diff --git a/utils/gyb_syntax_support/ExprNodes.py b/utils/gyb_syntax_support/ExprNodes.py
index e3ebe08..b3a10c7 100644
--- a/utils/gyb_syntax_support/ExprNodes.py
+++ b/utils/gyb_syntax_support/ExprNodes.py
@@ -50,6 +50,12 @@
Child('Identifier', kind='IdentifierToken'),
]),
+ # An 'super' expression.
+ Node('SuperRefExpr', kind='Expr',
+ children=[
+ Child('SuperKeyword', kind='SuperToken'),
+ ]),
+
# A nil expression.
Node('NilLiteralExpr', kind='Expr',
children=[
@@ -129,14 +135,6 @@
Child('FloatingDigits', kind='FloatingLiteralToken'),
]),
- Node('FunctionCallExpr', kind='Expr',
- children=[
- Child('CalledExpression', kind='Expr'),
- Child('LeftParen', kind='LeftParenToken'),
- Child('ArgumentList', kind='FunctionCallArgumentList'),
- Child('RightParen', kind='RightParenToken'),
- ]),
-
Node('TupleExpr', kind='Expr',
children=[
Child('LeftParen', kind='LeftParenToken'),
@@ -164,6 +162,13 @@
Child('RightSquare', kind='RightSquareToken'),
]),
+ # .foo
+ Node('ImplicitMemberExpr', kind='Expr',
+ children=[
+ Child("Dot", kind='PrefixPeriodToken'),
+ Child("Name", kind='Token')
+ ]),
+
# function-call-argument -> label? ':'? expression ','?
Node('FunctionCallArgument', kind='Syntax',
children=[
@@ -331,4 +336,50 @@
children=[
Child('Pattern', kind='Pattern'),
]),
+
+ # call-expr -> expr '(' call-argument-list ')' closure-expr?
+ # | expr closure-expr
+ Node('FunctionCallExpr', kind='Expr',
+ children=[
+ Child('CalledExpression', kind='Expr'),
+ Child('LeftParen', kind='LeftParenToken',
+ is_optional=True),
+ Child('ArgumentList', kind='FunctionCallArgumentList'),
+ Child('RightParen', kind='RightParenToken',
+ is_optional=True),
+ Child('TrailingClosure', kind='ClosureExpr',
+ is_optional=True),
+ ]),
+
+ # subscript-expr -> expr '[' call-argument-list ']' closure-expr?
+ Node('SubscriptExpr', kind='Expr',
+ children=[
+ Child('CalledExpression', kind='Expr'),
+ Child('LeftBracket', kind='LeftSquareBracketToken'),
+ Child('ArgumentList', kind='FunctionCallArgumentList'),
+ Child('RightBracket', kind='RightSquareBracketToken'),
+ Child('TrailingClosure', kind='ClosureExpr',
+ is_optional=True),
+ ]),
+
+ # optional-chaining-expr -> expr '?'
+ Node('OptionalChainingExpr', kind='Expr',
+ children=[
+ Child('Expression', kind='Expr'),
+ Child('QuetionMark', kind='PostfixQuestionMarkToken'),
+ ]),
+
+ # forced-value-expr -> expr '!'
+ Node('ForcedValueExpr', kind='Expr',
+ children=[
+ Child('Expression', kind='Expr'),
+ Child('ExclamationMark', kind='ExclamationMarkToken'),
+ ]),
+
+ # postfix-unary-expr -> expr postfix-operator
+ Node('PostfixUnaryExpr', kind='Expr',
+ children=[
+ Child('Expression', kind='Expr'),
+ Child('OperatorToken', kind='PostfixOperatorToken'),
+ ]),
]