Skip to content

Commit

Permalink
[IDE] Resolve [.]Type completion for (any P). to produce singleto…
Browse files Browse the repository at this point in the history
…n metatype instead of existential metatype.

Resolves #65843
  • Loading branch information
Rajveer100 committed Apr 20, 2024
1 parent bc4eeb8 commit 0fd78cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/IDE/CompletionLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,8 @@ void CompletionLookup::getPostfixKeywordCompletions(Type ExprType,
if (isa<TypeExpr>(ParsedExpr)) {
if (auto *T = ExprType->getAs<AnyMetatypeType>()) {
auto instanceTy = T->getInstanceType();
if (instanceTy->isAnyExistentialType()) {
if (instanceTy->isAnyExistentialType() &&
instanceTy->getCanonicalType()->is<ExistentialMetatypeType>()) {
addKeyword("Protocol", MetatypeType::get(instanceTy),
SemanticContextKind::CurrentNominal);
addKeyword("Type", ExistentialMetatypeType::get(instanceTy),
Expand Down
7 changes: 7 additions & 0 deletions test/IDE/issue-65843.swift
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0fd78cb

Please sign in to comment.