Skip to content

Commit 5ed21c6

Browse files
authored
Merge pull request #59328 from xedin/rdar-94619388
[TypeChecker/CodeCompletion] Re-introduce expression sanitization bef…
2 parents cc14811 + 3159591 commit 5ed21c6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,11 @@ bool TypeChecker::typeCheckForCodeCompletion(
571571
if (!node)
572572
return false;
573573

574+
if (auto *expr = getAsExpr(node)) {
575+
node = expr->walk(SanitizeExpr(Context,
576+
/*shouldReusePrecheckedType=*/false));
577+
}
578+
574579
CompletionContextFinder contextAnalyzer(node, DC);
575580

576581
// If there was no completion expr (e.g. if the code completion location was
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token COMPLETE
2+
3+
func foo(closure: (String) -> Void) -> String? {
4+
return nil
5+
}
6+
7+
func test() {
8+
if let key = foo(closure: { str in str.suffix(2) == #^COMPLETE^#

0 commit comments

Comments
 (0)