Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,11 +2196,15 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
// #keyPath is only available when the Objective-C runtime is.
if (!Ctx.LangOpts.EnableObjCInterop) return;

// After #, this is a very likely result. When just in a String context,
// it's not.
auto semanticContext = needPound ? SemanticContextKind::None
: SemanticContextKind::ExpressionSpecific;

CodeCompletionResultBuilder Builder(
Sink,
CodeCompletionResult::ResultKind::Keyword,
SemanticContextKind::ExpressionSpecific,
ExpectedTypes);
semanticContext, ExpectedTypes);
if (needPound)
Builder.addTextChunk("#keyPath");
else
Expand Down
2 changes: 1 addition & 1 deletion test/IDE/complete_pound_keypath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func completeInKeyPath2() {

// CHECK-AFTER_POUND: Keyword/ExprSpecific: keyPath({#@objc property sequence#}); name=keyPath(@objc property sequence)

// CHECK-KEYPATH_ARG: Keyword/ExprSpecific: #keyPath({#@objc property sequence#}); name=#keyPath(@objc property sequence)
// CHECK-KEYPATH_ARG: Keyword/None: #keyPath({#@objc property sequence#}); name=#keyPath(@objc property sequence)

// CHECK-IN_KEYPATH: Decl[InstanceVar]/CurrNominal: prop1[#String#]; name=prop1
// CHECK-IN_KEYPATH: Decl[InstanceVar]/CurrNominal: prop2[#ObjCClass?#]; name=prop2
Expand Down