Skip to content

Commit 84cd44f

Browse files
committed
---
yaml --- r: 349583 b: refs/heads/master-next c: a449960 h: refs/heads/master i: 349581: a7d7872 349579: 3649e1a 349575: 04287de 349567: 2c11f94
1 parent f77daee commit 84cd44f

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 1a7fb00debbc6dffe815f0832b2275368e484b40
3+
refs/heads/master-next: a4499607d53e1ae6737e3635cb8e3554a3b7ca65
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Parse/ParseType.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ Parser::TypeASTResult Parser::parseType(Diag<> MessageID,
391391
}
392392

393393
if (Tok.is(tok::arrow)) {
394+
auto InputNode = SyntaxContext->popIf<ParsedTypeSyntax>().getValue();
394395
// Handle type-function if we have an arrow.
395396
auto ArrowLoc = Tok.getLoc();
396397
auto Arrow = consumeTokenSyntax();
@@ -403,23 +404,21 @@ Parser::TypeASTResult Parser::parseType(Diag<> MessageID,
403404
}
404405
ParserResult<TypeRepr> SecondHalf =
405406
parseType(diag::expected_type_function_result);
407+
auto SecondTy = SyntaxContext->popIf<ParsedTypeSyntax>();
406408
if (SecondHalf.isParseError()) {
409+
SyntaxContext->addSyntax(InputNode);
407410
if (Throws)
408411
SyntaxContext->addSyntax(*Throws);
409412
SyntaxContext->addSyntax(Arrow);
413+
if (SecondTy)
414+
SyntaxContext->addSyntax(*SecondTy);
410415
if (SecondHalf.hasCodeCompletion())
411416
return makeParserCodeCompletionResult<TypeRepr>();
412417
if (SecondHalf.isNull())
413418
return nullptr;
414419
}
415420

416421
ParsedFunctionTypeSyntaxBuilder Builder(*SyntaxContext);
417-
Builder.useReturnType(SyntaxContext->popIf<ParsedTypeSyntax>().getValue());
418-
Builder.useArrow(Arrow);
419-
if (Throws)
420-
Builder.useThrowsOrRethrowsKeyword(*Throws);
421-
422-
auto InputNode = SyntaxContext->popIf<ParsedTypeSyntax>().getValue();
423422
bool isVoid = false;
424423
if (auto TupleTypeNode = InputNode.getAs<ParsedTupleTypeSyntax>()) {
425424
// Decompose TupleTypeSyntax and repack into FunctionType.
@@ -447,6 +446,13 @@ Parser::TypeASTResult Parser::parseType(Diag<> MessageID,
447446
Builder.addArgumentsMember(ParsedSyntaxRecorder::makeTupleTypeElement(
448447
InputNode, /*TrailingComma=*/None, *SyntaxContext));
449448
}
449+
450+
Builder.useReturnType(*SecondTy);
451+
if (Throws)
452+
Builder.useThrowsOrRethrowsKeyword(*Throws);
453+
Builder.useArrow(Arrow);
454+
Builder.useReturnType(*SecondTy);
455+
450456
SyntaxContext->addSyntax(Builder.build());
451457

452458
auto FunctionType = SyntaxContext->topNode<FunctionTypeSyntax>();
@@ -1107,21 +1113,20 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
11071113
// Parse the type annotation.
11081114
auto TypeLoc = Tok.getLoc();
11091115
auto TypeASTResult = parseType(diag::expected_type);
1116+
auto Type = SyntaxContext->popIf<ParsedTypeSyntax>();
11101117
if (TypeASTResult.hasCodeCompletion() || TypeASTResult.isNull()) {
11111118
Junk.append(LocalJunk.begin(), LocalJunk.end());
1112-
if (auto parsedT = SyntaxContext->popIf<ParsedTypeSyntax>())
1113-
Junk.push_back(*parsedT);
1119+
if (Type)
1120+
Junk.push_back(*Type);
11141121
skipListUntilDeclRBraceSyntax(Junk, LParenLoc, tok::r_paren, tok::comma);
11151122
return TypeASTResult.hasCodeCompletion()
11161123
? makeParserCodeCompletionStatus()
11171124
: makeParserError();
11181125
}
11191126

1120-
auto Type = *SyntaxContext->popIf<ParsedTypeSyntax>();
1121-
11221127
if (IsInOutObsoleted) {
11231128
bool IsTypeAlreadyAttributed = false;
1124-
if (auto AttributedType = Type.getAs<ParsedAttributedTypeSyntax>())
1129+
if (auto AttributedType = Type->getAs<ParsedAttributedTypeSyntax>())
11251130
IsTypeAlreadyAttributed = AttributedType->getDeferredSpecifier().hasValue();
11261131

11271132
if (IsTypeAlreadyAttributed) {
@@ -1167,7 +1172,7 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
11671172
Comma = consumeTokenSyntaxIf(tok::comma);
11681173

11691174
auto Element = ParsedSyntaxRecorder::makeTupleTypeElement(
1170-
InOut, Name, SecondName, Colon, Type, ElementEllipsis, Initializer,
1175+
InOut, Name, SecondName, Colon, *Type, ElementEllipsis, Initializer,
11711176
Comma, *SyntaxContext);
11721177

11731178
Junk.push_back(Element);

branches/master-next/test/Syntax/round_trip_misc.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ do {
1919
do {
2020
typealias Alias3 = (a b C,
2121
}
22+
do {
23+
typealias Alias3 = () -> @objc func
24+
}
2225

2326
// Orphan '}' at top level
2427
}

0 commit comments

Comments
 (0)