Skip to content

Commit 9e5a105

Browse files
authored
Merge pull request #77561 from hamishknight/completion-feedback
[Sema] NFC: Address review feedback on #77537
2 parents e96fc88 + d8ec851 commit 9e5a105

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

lib/Sema/CSApply.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,24 @@ namespace {
426426
solution(solution), target(target),
427427
SuppressDiagnostics(suppressDiagnostics) {}
428428

429+
ASTContext &getASTContext() const { return cs.getASTContext(); }
429430
ConstraintSystem &getConstraintSystem() const { return cs; }
430431

431432
void addLocalDeclToTypeCheck(Decl *D) {
433+
// If we're doing code completion, avoid doing any further type-checking,
434+
// that should instead be handled by TypeCheckASTNodeAtLocRequest.
435+
if (getASTContext().CompletionCallback)
436+
return;
437+
432438
LocalDeclsToTypeCheck.push_back(D);
433439
}
434440

435441
void addMacroToExpand(MacroExpansionExpr *E) {
442+
// If we're doing code completion, avoid doing any further type-checking,
443+
// that should instead be handled by TypeCheckASTNodeAtLocRequest.
444+
if (getASTContext().CompletionCallback)
445+
return;
446+
436447
MacrosToExpand.push_back(E);
437448
}
438449

@@ -5620,20 +5631,16 @@ namespace {
56205631
.fixItInsert(coercion->getStartLoc(), "consume ");
56215632
}
56225633

5623-
// If we're doing code completion, avoid doing any further type-checking,
5624-
// that should instead be handled by TypeCheckASTNodeAtLocRequest.
5625-
if (!ctx.CompletionCallback) {
5626-
// Type-check any local decls encountered.
5627-
for (auto *D : LocalDeclsToTypeCheck)
5628-
TypeChecker::typeCheckDecl(D);
5629-
5630-
// Expand any macros encountered.
5631-
// FIXME: Expansion should be lazy.
5632-
auto &eval = cs.getASTContext().evaluator;
5633-
for (auto *E : MacrosToExpand) {
5634-
(void)evaluateOrDefault(eval, ExpandMacroExpansionExprRequest{E},
5635-
std::nullopt);
5636-
}
5634+
// Type-check any local decls encountered.
5635+
for (auto *D : LocalDeclsToTypeCheck)
5636+
TypeChecker::typeCheckDecl(D);
5637+
5638+
// Expand any macros encountered.
5639+
// FIXME: Expansion should be lazy.
5640+
auto &eval = cs.getASTContext().evaluator;
5641+
for (auto *E : MacrosToExpand) {
5642+
(void)evaluateOrDefault(eval, ExpandMacroExpansionExprRequest{E},
5643+
std::nullopt);
56375644
}
56385645
}
56395646

0 commit comments

Comments
 (0)