From 66ad2a97b95c0f91fec56424eed91a47b9edf8f5 Mon Sep 17 00:00:00 2001 From: Pavel Yaskevich Date: Thu, 30 Oct 2025 00:02:44 -0700 Subject: [PATCH] [CSApply] NFC: Simplify solution application to `try` expressions Since `try!` now forces l-value -> r-value conversion during CSGen, let's simplify solution application to `try` expressions by coercing sub-expression to a type of a `try` itself which would introduce all necessary loads. --- lib/Sema/CSApply.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index f69f90c2fb466..db30109fb1f44 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -3752,26 +3752,12 @@ namespace { return expr; } - Expr *visitTryExpr(TryExpr *expr) { - return simplifyExprType(expr); - } + Expr *visitAnyTryExpr(AnyTryExpr *expr) { + simplifyExprType(expr); - Expr *visitForceTryExpr(ForceTryExpr *expr) { auto *subExpr = expr->getSubExpr(); - auto type = simplifyType(cs.getType(subExpr)); - - // Let's load the value associated with this try. - if (type->hasLValueType()) { - subExpr = coerceToType(subExpr, type->getRValueType(), - cs.getConstraintLocator(subExpr)); - - if (!subExpr) - return nullptr; - } - - cs.setType(expr, cs.getType(subExpr)); - expr->setSubExpr(subExpr); - + expr->setSubExpr(coerceToType(subExpr, cs.getType(expr), + cs.getConstraintLocator(subExpr))); return expr; }