Skip to content

Commit ae5bb41

Browse files
committed
[CodeCompletion] Don't typecheck expression if result builder transform was applied
1 parent 781b481 commit ae5bb41

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,18 +1939,18 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(Evaluator &evaluator,
19391939
if (Type builderType = getResultBuilderType(func)) {
19401940
auto optBody =
19411941
TypeChecker::applyResultBuilderBodyTransform(func, builderType);
1942+
if (ctx.CompletionCallback && ctx.CompletionCallback->gotCallback()) {
1943+
// We already informed the completion callback of solutions found by
1944+
// type checking the entire result builder from
1945+
// applyResultBuilderBodyTransform. No need to typecheck the requested
1946+
// AST node individually anymore.
1947+
return false;
1948+
}
19421949
if (optBody && *optBody) {
19431950
// Wire up the function body now.
19441951
func->setBody(*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
19451952
return false;
19461953
}
1947-
// FIXME: We failed to apply the result builder transform. Fall back to
1948-
// just type checking the node that contains the code completion token.
1949-
// This may be missing some context from the result builder but in
1950-
// practice it often contains sufficient information to provide a decent
1951-
// level of code completion that's better than providing nothing at all.
1952-
// The proper solution would be to only partially type check the result
1953-
// builder so that this fall back would not be necessary.
19541954
} else if (func->hasSingleExpressionBody() &&
19551955
func->getResultInterfaceType()->isVoid()) {
19561956
// The function returns void. We don't need an explicit return, no matter

0 commit comments

Comments
 (0)