Skip to content

Commit 7a48ca7

Browse files
authored
Merge pull request #73709 from hamishknight/skip-placeholder-6.0
[6.0] [CS] Avoid creating placeholder var if skipping for completion
2 parents 5e12567 + 9678328 commit 7a48ca7

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ class ResultBuilderTransform
197197
return std::nullopt;
198198
}
199199

200-
// Allocate variable with a placeholder type
201-
auto *resultVar = buildPlaceholderVar(stmt->getStartLoc(), newBody);
202-
203200
if (ctx.CompletionCallback && stmt->getSourceRange().isValid() &&
204201
!containsIDEInspectionTarget(stmt->getSourceRange(), ctx.SourceMgr) &&
205202
!isa<GuardStmt>(stmt)) {
@@ -209,6 +206,9 @@ class ResultBuilderTransform
209206
return std::nullopt;
210207
}
211208

209+
// Allocate variable with a placeholder type
210+
auto *resultVar = buildPlaceholderVar(stmt->getStartLoc(), newBody);
211+
212212
auto result = visit(stmt, resultVar);
213213
if (!result)
214214
return UnsupportedElt(stmt);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %batch-code-completion
2+
3+
@resultBuilder struct MyBuilder {
4+
static func buildBlock(_ components: [Int]...) -> [Int]
5+
static func buildFinalResult(_ component: [Int]) -> Int
6+
}
7+
8+
func build(@MyBuilder itemsBuilder: () -> Int) {}
9+
10+
func test() {
11+
let modifiers = build {
12+
for modifier in invalid {
13+
}
14+
}
15+
16+
modifiers.#^COMPLETE^#
17+
}
18+
19+
// COMPLETE: Keyword[self]/CurrNominal: self[#Void#]; name=self

0 commit comments

Comments
 (0)