diff --git a/lib/IDE/CompletionLookup.cpp b/lib/IDE/CompletionLookup.cpp index a92e2a345e60e..e2151341ab39c 100644 --- a/lib/IDE/CompletionLookup.cpp +++ b/lib/IDE/CompletionLookup.cpp @@ -2437,7 +2437,8 @@ void CompletionLookup::getPostfixKeywordCompletions(Type ExprType, if (isa(ParsedExpr)) { if (auto *T = ExprType->getAs()) { auto instanceTy = T->getInstanceType(); - if (instanceTy->isAnyExistentialType()) { + if (instanceTy->isAnyExistentialType() && + instanceTy->getCanonicalType()->is()) { addKeyword("Protocol", MetatypeType::get(instanceTy), SemanticContextKind::CurrentNominal); addKeyword("Type", ExistentialMetatypeType::get(instanceTy), diff --git a/test/IDE/issue-65843.swift b/test/IDE/issue-65843.swift new file mode 100644 index 0000000000000..75e1fb36b1036 --- /dev/null +++ b/test/IDE/issue-65843.swift @@ -0,0 +1,7 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t + +protocol P {} + +(any P).#^COMPLETE?check=META^# +// META: Keyword/CurrNominal: Type[#(any P).Type#]; name=Type