@@ -435,6 +435,18 @@ bool ConstraintSystem::containsIDEInspectionTarget(
435435 Context.SourceMgr );
436436}
437437
438+ void ConstraintSystem::recordPotentialThrowSite (
439+ CatchNode catchNode, PotentialThrowSite site) {
440+ potentialThrowSites.push_back ({catchNode, site});
441+ if (solverState)
442+ recordChange (SolverTrail::Change::RecordedPotentialThrowSite (catchNode));
443+ }
444+
445+ void ConstraintSystem::removePotentialThrowSite (CatchNode catchNode) {
446+ ASSERT (potentialThrowSites.back ().first == catchNode);
447+ potentialThrowSites.pop_back ();
448+ }
449+
438450void ConstraintSystem::recordPotentialThrowSite (
439451 PotentialThrowSite::Kind kind, Type type,
440452 ConstraintLocatorBuilder locator) {
@@ -461,9 +473,8 @@ void ConstraintSystem::recordPotentialThrowSite(
461473 // do..catch statements without an explicit `throws` clause do infer
462474 // thrown types.
463475 if (auto doCatch = catchNode.dyn_cast <DoCatchStmt *>()) {
464- potentialThrowSites.push_back (
465- {catchNode,
466- PotentialThrowSite{kind, type, getConstraintLocator (locator)}});
476+ PotentialThrowSite site{kind, type, getConstraintLocator (locator)};
477+ recordPotentialThrowSite (catchNode, site);
467478 return ;
468479 }
469480
@@ -476,9 +487,8 @@ void ConstraintSystem::recordPotentialThrowSite(
476487 if (!closureEffects (closure).isThrowing ())
477488 return ;
478489
479- potentialThrowSites.push_back (
480- {catchNode,
481- PotentialThrowSite{kind, type, getConstraintLocator (locator)}});
490+ PotentialThrowSite site{kind, type, getConstraintLocator (locator)};
491+ recordPotentialThrowSite (catchNode, site);
482492}
483493
484494Type ConstraintSystem::getCaughtErrorType (CatchNode catchNode) {
0 commit comments