Skip to content

Commit 3eabc0d

Browse files
authored
Merge pull request #27757 from rintaro/syntaxparse-orphantypealias
[SyntaxParse] Don't discard 'typealias' without identifier
2 parents 3f5d250 + 9e99707 commit 3eabc0d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4097,8 +4097,10 @@ parseDeclTypeAlias(Parser::ParseDeclOptions Flags, DeclAttributes &Attributes) {
40974097
Status |= parseIdentifierDeclName(
40984098
*this, Id, IdLoc, "typealias",
40994099
[](const Token &next) { return next.isAny(tok::colon, tok::equal); });
4100-
if (Status.isError())
4100+
if (Status.isError()) {
4101+
TmpCtxt->setTransparent();
41014102
return nullptr;
4103+
}
41024104

41034105
DebuggerContextChange DCC(*this, Id, DeclKind::TypeAlias);
41044106

test/Syntax/round_trip_misc.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ class C {
1010
func f() {}
1111
}
1212
}
13+
do {
14+
typealias Alias2 = () -> (a b: [Generic<Int
15+
}
16+
do {
17+
typealias Alias3 = (a b C,
18+
}
19+
do {
20+
typealias Alias3 = () -> @objc func
21+
}
22+
do {
23+
typealias
24+
}
25+
do {
26+
typealias Alias = A & B & C.D<>
27+
}
28+
do {
29+
typealias boo bar = Int
30+
}
1331

1432
// Orphan '}' at top level
1533
}

0 commit comments

Comments
 (0)