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 @@ -3417,7 +3417,21 @@ namespace {
3417
3417
}
3418
3418
3419
3419
Expr *visitAnyTryExpr (AnyTryExpr *expr) {
3420
- cs.setType (expr, cs.getType (expr->getSubExpr ()));
3420
+ auto *subExpr = expr->getSubExpr ();
3421
+ auto type = simplifyType (cs.getType (subExpr));
3422
+
3423
+ // Let's load the value associated with this try.
3424
+ if (type->hasLValueType ()) {
3425
+ subExpr = coerceToType (subExpr, type->getRValueType (),
3426
+ cs.getConstraintLocator (subExpr));
3427
+
3428
+ if (!subExpr)
3429
+ return nullptr ;
3430
+ }
3431
+
3432
+ cs.setType (expr, cs.getType (subExpr));
3433
+ expr->setSubExpr (subExpr);
3434
+
3421
3435
return expr;
3422
3436
}
3423
3437
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