Skip to content

Commit 7193766

Browse files
committed
[IDE] Don’t return any result if the base expression’s type in postfix completion couldn’t be inferred
1 parent c7e0bfa commit 7193766

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/IDE/PostfixCompletion.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ void PostfixCompletionCallback::sawSolutionImpl(
156156
auto *ParsedExpr = CompletionExpr->getBase();
157157
auto *SemanticExpr = ParsedExpr->getSemanticsProvidingExpr();
158158

159+
if (!S.hasType(ParsedExpr)) {
160+
return;
161+
}
162+
159163
auto BaseTy = getTypeForCompletion(S, ParsedExpr);
160164
// If base type couldn't be determined (e.g. because base expression
161165
// is an invalid reference), let's not attempt to do a lookup since

test/IDE/complete_pattern.swift

+10
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,13 @@ func testCompleteAfterPatternInClosure() {
225225

226226
// AFTER_PATTERN_IN_CLOSURE-NOT: Begin completions
227227
}
228+
229+
func testIfLetInClosure(foo: Int?) {
230+
func takeClosure(_ x: () -> Void) {}
231+
232+
takeClosure {
233+
if let items#^IF_LET_IN_CLOSURE^# = foo {
234+
}
235+
}
236+
// IF_LET_IN_CLOSURE-NOT: Begin completions
237+
}

0 commit comments

Comments
 (0)