@@ -2587,18 +2587,22 @@ bool TypeCheckASTNodeAtLocRequest::evaluate(
2587
2587
func, builderType,
2588
2588
/* ClosuresInResultBuilderDontParticipateInInference=*/
2589
2589
ctx.CompletionCallback == nullptr && ctx.SolutionCallback == nullptr );
2590
- if (optBody && *optBody) {
2590
+ if (ctx.CompletionCallback && ctx.CompletionCallback ->gotCallback ()) {
2591
+ // We already informed the completion callback of solutions found by
2592
+ // type checking the entire result builder from
2593
+ // applyResultBuilderBodyTransform. No need to typecheck the requested
2594
+ // AST node individually anymore.
2595
+ return false ;
2596
+ }
2597
+ if (!ctx.CompletionCallback && !ctx.SolutionCallback && optBody && *optBody) {
2591
2598
// Wire up the function body now.
2592
2599
func->setBody (*optBody, AbstractFunctionDecl::BodyKind::TypeChecked);
2593
2600
return false ;
2594
2601
}
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
+ // We did not find a solution while applying the result builder, possibly
2603
+ // because the result builder contained an invalid element and thus the
2604
+ // transform couldn't be applied. Perform code completion pretending there
2605
+ // was no result builder to recover.
2602
2606
} else if (func->hasSingleExpressionBody () &&
2603
2607
func->getResultInterfaceType ()->isVoid ()) {
2604
2608
// The function returns void. We don't need an explicit return, no matter
0 commit comments