Skip to content

Commit 8f433ee

Browse files
committed
[Completion] Don't complete call arguments after .
Completing call argument patterns here is invalid. rdar://127760308
1 parent da6f015 commit 8f433ee

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,8 @@ void CodeCompletionCallbacksImpl::postfixCompletion(SourceLoc CompletionLoc,
14841484
// closure. In that case, also suggest labels for additional trailing
14851485
// closures.
14861486
if (auto AE = dyn_cast<ApplyExpr>(ParsedExpr)) {
1487-
if (AE->getArgs()->hasAnyTrailingClosures()) {
1487+
if (AE->getArgs()->hasAnyTrailingClosures() &&
1488+
Kind == CompletionKind::PostfixExpr) {
14881489
ASTContext &Ctx = CurDeclContext->getASTContext();
14891490

14901491
// Modify the call that has the code completion expression as an

test/IDE/complete_multiple_trailingclosure.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ func testOptionalInit() {
9999
// INIT_OPTIONAL_NEWLINE-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
100100
}
101101

102+
func testOptionalInitDot() {
103+
// When there's a dot, we don't complete for the closure argument.
104+
TestStruct2 {
105+
2
106+
}
107+
.#^INIT_OPTIONAL_DOT^#
108+
// INIT_OPTIONAL_DOT: Begin completions, 2 items
109+
// INIT_OPTIONAL_DOT-DAG: Keyword[self]/CurrNominal: self[#TestStruct2#]; name=self
110+
// INIT_OPTIONAL_DOT-DAG: Decl[InstanceMethod]/CurrNominal: testStructMethod()[#Void#]; name=testStructMethod()
111+
}
112+
102113
struct TestStruct3 {
103114
init(fn1: () -> Int, fn2: () -> String, fn3: () -> String) {}
104115
func testStructMethod() {}

0 commit comments

Comments
 (0)