File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
validation-test/Sema/type_checker_crashers_fixed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -3412,7 +3412,21 @@ namespace {
34123412 }
34133413
34143414 Expr *visitAnyTryExpr (AnyTryExpr *expr) {
3415- cs.setType (expr, cs.getType (expr->getSubExpr ()));
3415+ auto *subExpr = expr->getSubExpr ();
3416+ auto type = simplifyType (cs.getType (subExpr));
3417+
3418+ // Let's load the value associated with this try.
3419+ if (type->hasLValueType ()) {
3420+ subExpr = coerceToType (subExpr, type->getRValueType (),
3421+ cs.getConstraintLocator (subExpr));
3422+
3423+ if (!subExpr)
3424+ return nullptr ;
3425+ }
3426+
3427+ cs.setType (expr, cs.getType (subExpr));
3428+ expr->setSubExpr (subExpr);
3429+
34163430 return expr;
34173431 }
34183432
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend %s -typecheck
2+
3+ struct Info {
4+ }
5+
6+ class Test {
7+ var info : Info = Info ( )
8+
9+ init ( ) throws { }
10+ }
11+
12+ _ = try Test ( ) . info // Ok
13+ _ = try ! Test ( ) . info // Ok
You can’t perform that action at this time.
0 commit comments