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 {
3412
3412
}
3413
3413
3414
3414
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
+
3416
3430
return expr;
3417
3431
}
3418
3432
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