Skip to content

Commit 66ad2a9

Browse files
committed
[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.
1 parent 778281a commit 66ad2a9

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3752,26 +3752,12 @@ namespace {
37523752
return expr;
37533753
}
37543754

3755-
Expr *visitTryExpr(TryExpr *expr) {
3756-
return simplifyExprType(expr);
3757-
}
3755+
Expr *visitAnyTryExpr(AnyTryExpr *expr) {
3756+
simplifyExprType(expr);
37583757

3759-
Expr *visitForceTryExpr(ForceTryExpr *expr) {
37603758
auto *subExpr = expr->getSubExpr();
3761-
auto type = simplifyType(cs.getType(subExpr));
3762-
3763-
// Let's load the value associated with this try.
3764-
if (type->hasLValueType()) {
3765-
subExpr = coerceToType(subExpr, type->getRValueType(),
3766-
cs.getConstraintLocator(subExpr));
3767-
3768-
if (!subExpr)
3769-
return nullptr;
3770-
}
3771-
3772-
cs.setType(expr, cs.getType(subExpr));
3773-
expr->setSubExpr(subExpr);
3774-
3759+
expr->setSubExpr(coerceToType(subExpr, cs.getType(expr),
3760+
cs.getConstraintLocator(subExpr)));
37753761
return expr;
37763762
}
37773763

0 commit comments

Comments
 (0)