Skip to content

Commit 1ee1fbf

Browse files
committed
[CodeCompletion] Don't typecheck expression if result builder transform was applied
1 parent 2383fc3 commit 1ee1fbf

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
@@ -1972,18 +1972,18 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
19721972
if (Type builderType = getResultBuilderType(func)) {
19731973
auto optBody =
19741974
TypeChecker::applyResultBuilderBodyTransform(func, builderType);
1975+
if (ctx.CompletionCallback && ctx.CompletionCallback->gotCallback()) {
1976+
// We already informed the completion callback of solutions found by
1977+
// type checking the entire result builder from
1978+
// applyResultBuilderBodyTransform. No need to typecheck the requested
1979+
// AST node individually anymore.
1980+
return false;
1981+
}
19751982
if (optBody && *optBody) {
19761983
// Wire up the function body now.
19771984
func->setBody(*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
19781985
return false;
19791986
}
1980-
// FIXME: We failed to apply the result builder transform. Fall back to
1981-
// just type checking the node that contains the code completion token.
1982-
// This may be missing some context from the result builder but in
1983-
// practice it often contains sufficient information to provide a decent
1984-
// level of code completion that's better than providing nothing at all.
1985-
// The proper solution would be to only partially type check the result
1986-
// builder so that this fall back would not be necessary.
19871987
} else if (func->hasSingleExpressionBody() &&
19881988
func->getResultInterfaceType()->isVoid()) {
19891989
// The function returns void. We don't need an explicit return, no matter

0 commit comments

Comments
 (0)