[Typed throws] Enable checking of thrown types on closures.

Enable typed throws on explicit closures, either due to contextual
type information or due to explicit specification.
This commit is contained in:
Doug Gregor
2023-09-19 19:57:50 -07:00
parent 54589e12f5
commit 7f82b2a9aa
7 changed files with 123 additions and 6 deletions

View File

@@ -5809,6 +5809,16 @@ void constraints::simplifyLocator(ASTNode &anchor,
}
break;
case ConstraintLocator::ClosureThrownError:
if (auto CE = getAsExpr<ClosureExpr>(anchor)) {
if (auto thrownTypeRepr = CE->getExplicitThrownTypeRepr()) {
anchor = thrownTypeRepr;
path = path.slice(1);
break;
}
}
break;
case ConstraintLocator::CoercionOperand: {
auto *CE = castToExpr<CoerceExpr>(anchor);
anchor = CE->getSubExpr()->getValueProvidingExpr();