Skip to content

Commit 987b856

Browse files
authored
Merge pull request #26952 from rintaro/syntaxparse-type-failedpostfix
[SyntaxParse] Don't parse postfix if faield to parse type identifier
2 parents 4fa3cef + 23fe5ed commit 987b856

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/Parse/ParseType.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,9 @@ Parser::TypeResult Parser::parseTypeSimple(Diag<> MessageID,
209209
}
210210

211211
// '.Type', '.Protocol', '?', '!', and '[]' still leave us with type-simple.
212-
while (Result->isSuccess() || !Result->getUnknownNodes().empty()) {
213-
auto PrevType = Result->isSuccess()
214-
? Result->getResult()
215-
: ParsedSyntaxRecorder::makeUnknownType(
216-
Result->getUnknownNodes(), *SyntaxContext);
212+
while (Result->isSuccess()) {
213+
auto PrevType = Result->getResult();
214+
217215
if ((Tok.is(tok::period) || Tok.is(tok::period_prefix)) &&
218216
(peekToken().isContextualKeyword("Type") ||
219217
peekToken().isContextualKeyword("Protocol"))) {
@@ -236,9 +234,6 @@ Parser::TypeResult Parser::parseTypeSimple(Diag<> MessageID,
236234
continue;
237235
}
238236
}
239-
if (!Result->isSuccess())
240-
Result =
241-
makeParsedResult<ParsedTypeSyntax>({PrevType}, Result->getStatus());
242237
break;
243238
}
244239

test/IDE/complete_type.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@
400400
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNBOUND_DOT | %FileCheck %s -check-prefix=UNBOUND_DOT
401401
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNBOUND_DOT_2 | %FileCheck %s -check-prefix=UNBOUND_DOT_2
402402

403+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERICARG_OPTIONAL | %FileCheck %s -check-prefix=GENERICARG_OPTIONAL
404+
403405
//===--- Helper types that are used in this test
404406

405407
struct FooStruct {
@@ -1129,3 +1131,6 @@ func testUnbound2(x: OuterStruct<Int>.Inner.#^UNBOUND_DOT_2^#) {}
11291131
// UNBOUND_DOT_2: Begin completions
11301132
// UNBOUND_DOT_2-DAG: Keyword/None: Type[#OuterStruct<Int>.Inner.Type#]; name=Type
11311133
// UNBOUND_DOT_2: End completions
1134+
1135+
func testGenericArgForOptional() -> Set<#^GENERICARG_OPTIONAL^#>? {}
1136+
// GENERICARG_OPTIONAL: Begin completions

0 commit comments

Comments
 (0)