@@ -2583,22 +2583,25 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
2583
2583
// Function builder function doesn't support partial type checking.
2584
2584
if (auto *func = dyn_cast<FuncDecl>(DC)) {
2585
2585
if (Type builderType = getResultBuilderType (func)) {
2586
- auto optBody = TypeChecker::applyResultBuilderBodyTransform (
2587
- func, builderType,
2588
- /* ClosuresInResultBuilderDontParticipateInInference=*/
2589
- ctx.CompletionCallback == nullptr && ctx.SolutionCallback == nullptr );
2590
- if (optBody && *optBody) {
2591
- // Wire up the function body now.
2592
- func->setBody (*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
2593
- return false ;
2586
+ if (func->getBody ()) {
2587
+ auto optBody = TypeChecker::applyResultBuilderBodyTransform (
2588
+ func, builderType,
2589
+ /* ClosuresInResultBuilderDontParticipateInInference=*/
2590
+ ctx.CompletionCallback == nullptr &&
2591
+ ctx.SolutionCallback == nullptr );
2592
+ if (optBody && *optBody) {
2593
+ // Wire up the function body now.
2594
+ func->setBody (*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
2595
+ return false ;
2596
+ }
2597
+ // FIXME: We failed to apply the result builder transform. Fall back to
2598
+ // just type checking the node that contains the code completion token.
2599
+ // This may be missing some context from the result builder but in
2600
+ // practice it often contains sufficient information to provide a decent
2601
+ // level of code completion that's better than providing nothing at all.
2602
+ // The proper solution would be to only partially type check the result
2603
+ // builder so that this fall back would not be necessary.
2594
2604
}
2595
- // FIXME: We failed to apply the result builder transform. Fall back to
2596
- // just type checking the node that contains the code completion token.
2597
- // This may be missing some context from the result builder but in
2598
- // practice it often contains sufficient information to provide a decent
2599
- // level of code completion that's better than providing nothing at all.
2600
- // The proper solution would be to only partially type check the result
2601
- // builder so that this fall back would not be necessary.
2602
2605
} else if (func->hasSingleExpressionBody () &&
2603
2606
func->getResultInterfaceType ()->isVoid ()) {
2604
2607
// The function returns void. We don't need an explicit return, no matter
0 commit comments