Skip to content

Commit 1bacfe9

Browse files
committed
[IDE] Ignore unspported constructs in result builders in code completion mode
1 parent 7193766 commit 1bacfe9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ class ResultBuilderTransform
264264
for (auto element : braceStmt->getElements()) {
265265
if (auto unsupported =
266266
transformBraceElement(element, newBody, buildBlockArguments)) {
267-
return failTransform(*unsupported);
267+
// When in code completion mode, simply ignore unsported constructs to
268+
// get results for anything that's unrelated to the unsupported
269+
// constructs.
270+
if (!ctx.CompletionCallback) {
271+
return failTransform(*unsupported);
272+
}
268273
}
269274
}
270275

@@ -1171,7 +1176,7 @@ ConstraintSystem::matchResultBuilder(AnyFunctionRef fn, Type builderType,
11711176
auto *body = transform.apply(fn.getBody());
11721177

11731178
if (auto unsupported = transform.getUnsupportedElement()) {
1174-
assert(!body);
1179+
assert(!body || getASTContext().CompletionCallback);
11751180

11761181
// If we aren't supposed to attempt fixes, fail.
11771182
if (!shouldAttemptFixes()) {

lib/Sema/CSStep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ StepResult ConjunctionStep::resume(bool prevFailed) {
959959

960960
if (Solutions.size() == 1) {
961961
auto score = Solutions.front().getFixedScore();
962-
if (score.Data[SK_Fix] > 0)
962+
if (score.Data[SK_Fix] > 0 && !CS.getASTContext().CompletionCallback)
963963
Producer.markExhausted();
964964
}
965965
} else if (Solutions.size() != 1) {

0 commit comments

Comments
 (0)