mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CSApply] Load l-value before wrapping it in try expression
Just like `try?` other types of try - `try` and `try!` have to load the value before using it. Resolve: rdar://78102266
This commit is contained in:
@@ -3412,7 +3412,21 @@ namespace {
|
||||
}
|
||||
|
||||
Expr *visitAnyTryExpr(AnyTryExpr *expr) {
|
||||
cs.setType(expr, cs.getType(expr->getSubExpr()));
|
||||
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);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user