From 5a6e14bee4236a36613026c22114e19dc645bafb Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Mon, 14 Oct 2019 14:02:05 -0700 Subject: [PATCH] Revert "Merge pull request #26952 from rintaro/syntaxparse-type-failedpostfix" This reverts commit 987b856f14fe463f4af9ce4b5ebdb83115bd87dc, reversing changes made to 4fa3cef4c422bb73d66f5bb54dffed4de1257a70. --- lib/Parse/ParseType.cpp | 11 ++++++++--- test/IDE/complete_type.swift | 5 ----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Parse/ParseType.cpp b/lib/Parse/ParseType.cpp index 46bbdddbb9314..8b08eeb2a9ff0 100644 --- a/lib/Parse/ParseType.cpp +++ b/lib/Parse/ParseType.cpp @@ -210,9 +210,11 @@ Parser::TypeResult Parser::parseTypeSimple(Diag<> MessageID, } // '.Type', '.Protocol', '?', '!', and '[]' still leave us with type-simple. - while (Result->isSuccess()) { - auto PrevType = Result->getResult(); - + while (Result->isSuccess() || !Result->getUnknownNodes().empty()) { + auto PrevType = Result->isSuccess() + ? Result->getResult() + : ParsedSyntaxRecorder::makeUnknownType( + Result->getUnknownNodes(), *SyntaxContext); if ((Tok.is(tok::period) || Tok.is(tok::period_prefix)) && (peekToken().isContextualKeyword("Type") || peekToken().isContextualKeyword("Protocol"))) { @@ -235,6 +237,9 @@ Parser::TypeResult Parser::parseTypeSimple(Diag<> MessageID, continue; } } + if (!Result->isSuccess()) + Result = + makeParsedResult({PrevType}, Result->getStatus()); break; } diff --git a/test/IDE/complete_type.swift b/test/IDE/complete_type.swift index 8b5ef8fe2f1b4..93334e7f0e124 100644 --- a/test/IDE/complete_type.swift +++ b/test/IDE/complete_type.swift @@ -400,8 +400,6 @@ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNBOUND_DOT | %FileCheck %s -check-prefix=UNBOUND_DOT // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=UNBOUND_DOT_2 | %FileCheck %s -check-prefix=UNBOUND_DOT_2 -// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERICARG_OPTIONAL | %FileCheck %s -check-prefix=GENERICARG_OPTIONAL - //===--- Helper types that are used in this test struct FooStruct { @@ -1131,6 +1129,3 @@ func testUnbound2(x: OuterStruct.Inner.#^UNBOUND_DOT_2^#) {} // UNBOUND_DOT_2: Begin completions // UNBOUND_DOT_2-DAG: Keyword/None: Type[#OuterStruct.Inner.Type#]; name=Type // UNBOUND_DOT_2: End completions - -func testGenericArgForOptional() -> Set<#^GENERICARG_OPTIONAL^#>? {} -// GENERICARG_OPTIONAL: Begin completions