@@ -2365,6 +2365,24 @@ Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
2365
2365
SmallVector<Solution, 4 > solutions;
2366
2366
bool solvingFailed = cs.solve (solutions);
2367
2367
2368
+ auto reportSolutionsToSolutionCallback = [&](const SolutionResult &result) {
2369
+ if (!cs.getASTContext ().SolutionCallback ) {
2370
+ return ;
2371
+ }
2372
+ switch (result.getKind ()) {
2373
+ case SolutionResult::Success:
2374
+ cs.getASTContext ().SolutionCallback ->sawSolution (result.getSolution ());
2375
+ break ;
2376
+ case SolutionResult::Ambiguous:
2377
+ for (auto &solution : result.getAmbiguousSolutions ()) {
2378
+ cs.getASTContext ().SolutionCallback ->sawSolution (solution);
2379
+ }
2380
+ break ;
2381
+ default :
2382
+ break ;
2383
+ }
2384
+ };
2385
+
2368
2386
if (solvingFailed || solutions.size () != 1 ) {
2369
2387
// Try to fix the system or provide a decent diagnostic.
2370
2388
auto salvagedResult = cs.salvage ();
@@ -2376,14 +2394,17 @@ Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
2376
2394
2377
2395
case SolutionResult::Kind::Error:
2378
2396
case SolutionResult::Kind::Ambiguous:
2397
+ reportSolutionsToSolutionCallback (salvagedResult);
2379
2398
return nullptr ;
2380
2399
2381
2400
case SolutionResult::Kind::UndiagnosedError:
2401
+ reportSolutionsToSolutionCallback (salvagedResult);
2382
2402
cs.diagnoseFailureFor (SolutionApplicationTarget (func));
2383
2403
salvagedResult.markAsDiagnosed ();
2384
2404
return nullptr ;
2385
2405
2386
2406
case SolutionResult::Kind::TooComplex:
2407
+ reportSolutionsToSolutionCallback (salvagedResult);
2387
2408
func->diagnose (diag::expression_too_complex)
2388
2409
.highlight (func->getBodySourceRange ());
2389
2410
salvagedResult.markAsDiagnosed ();
@@ -2401,6 +2422,13 @@ Optional<BraceStmt *> TypeChecker::applyResultBuilderBodyTransform(
2401
2422
log << ' \n ' ;
2402
2423
}
2403
2424
2425
+ if (cs.getASTContext ().SolutionCallback ) {
2426
+ for (auto &solution : solutions) {
2427
+ cs.getASTContext ().SolutionCallback ->sawSolution (solution);
2428
+ }
2429
+ return nullptr ;
2430
+ }
2431
+
2404
2432
// FIXME: Shouldn't need to do this.
2405
2433
cs.applySolution (solutions.front ());
2406
2434
0 commit comments