Skip to content

Commit ac3ae8d

Browse files
benlangmuirtkremenek
authored andcommitted
[CodeCompletion] Don't mark #keyPath as "expression specific" without # (#2797)
We suggest #keyPath in every String context, so having it be expression-specific is artificially increasing its priority. rdar://problem/26544672
1 parent b921dae commit ac3ae8d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,11 +2196,15 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
21962196
// #keyPath is only available when the Objective-C runtime is.
21972197
if (!Ctx.LangOpts.EnableObjCInterop) return;
21982198

2199+
// After #, this is a very likely result. When just in a String context,
2200+
// it's not.
2201+
auto semanticContext = needPound ? SemanticContextKind::None
2202+
: SemanticContextKind::ExpressionSpecific;
2203+
21992204
CodeCompletionResultBuilder Builder(
22002205
Sink,
22012206
CodeCompletionResult::ResultKind::Keyword,
2202-
SemanticContextKind::ExpressionSpecific,
2203-
ExpectedTypes);
2207+
semanticContext, ExpectedTypes);
22042208
if (needPound)
22052209
Builder.addTextChunk("#keyPath");
22062210
else

test/IDE/complete_pound_keypath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func completeInKeyPath2() {
3636

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

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

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

0 commit comments

Comments
 (0)