@@ -2560,22 +2560,25 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
2560
2560
// Function builder function doesn't support partial type checking.
2561
2561
if (auto *func = dyn_cast<FuncDecl>(DC)) {
2562
2562
if (Type builderType = getResultBuilderType (func)) {
2563
- auto optBody = TypeChecker::applyResultBuilderBodyTransform (
2564
- func, builderType,
2565
- /* ClosuresInResultBuilderDontParticipateInInference=*/
2566
- ctx.CompletionCallback == nullptr && ctx.SolutionCallback == nullptr );
2567
- if (optBody && *optBody) {
2568
- // Wire up the function body now.
2569
- func->setBody (*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
2570
- return false ;
2563
+ if (func->getBody ()) {
2564
+ auto optBody = TypeChecker::applyResultBuilderBodyTransform (
2565
+ func, builderType,
2566
+ /* ClosuresInResultBuilderDontParticipateInInference=*/
2567
+ ctx.CompletionCallback == nullptr &&
2568
+ ctx.SolutionCallback == nullptr );
2569
+ if (optBody && *optBody) {
2570
+ // Wire up the function body now.
2571
+ func->setBody (*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
2572
+ return false ;
2573
+ }
2574
+ // FIXME: We failed to apply the result builder transform. Fall back to
2575
+ // just type checking the node that contains the code completion token.
2576
+ // This may be missing some context from the result builder but in
2577
+ // practice it often contains sufficient information to provide a decent
2578
+ // level of code completion that's better than providing nothing at all.
2579
+ // The proper solution would be to only partially type check the result
2580
+ // builder so that this fall back would not be necessary.
2571
2581
}
2572
- // FIXME: We failed to apply the result builder transform. Fall back to
2573
- // just type checking the node that contains the code completion token.
2574
- // This may be missing some context from the result builder but in
2575
- // practice it often contains sufficient information to provide a decent
2576
- // level of code completion that's better than providing nothing at all.
2577
- // The proper solution would be to only partially type check the result
2578
- // builder so that this fall back would not be necessary.
2579
2582
} else if (func->hasSingleExpressionBody () &&
2580
2583
func->getResultInterfaceType ()->isVoid ()) {
2581
2584
// The function returns void. We don't need an explicit return, no matter
0 commit comments