File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -3104,6 +3104,8 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
31043104
31053105 if (auto thrownError = TypeChecker::canThrow (Ctx, E->getSubExpr ())) {
31063106 E->setThrownError (*thrownError);
3107+ } else {
3108+ E->setThrownError (Ctx.getNeverType ());
31073109 }
31083110
31093111 scope.preserveCoverageFromOptionalOrForcedTryOperand ();
@@ -3123,6 +3125,8 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
31233125
31243126 if (auto thrownError = TypeChecker::canThrow (Ctx, E->getSubExpr ())) {
31253127 E->setThrownError (*thrownError);
3128+ } else {
3129+ E->setThrownError (Ctx.getNeverType ());
31263130 }
31273131
31283132 scope.preserveCoverageFromOptionalOrForcedTryOperand ();
Original file line number Diff line number Diff line change @@ -37,3 +37,15 @@ func throwsAnything() throws {
3737 // CHECK: optional_try_expr{{.*}}thrown_error="MyError"
3838 try ? printOrFail ( " ssshhhhh " )
3939}
40+
41+ func doesNotThrow( ) { }
42+
43+ func throwsNothing( ) {
44+ // CHECK-LABE: func_decl{{.*}}"throwsNothing()"
45+
46+ // CHECK: force_try_expr{{.*}}thrown_error="Never"
47+ try ! doesNotThrow ( )
48+
49+ // CHECK: optional_try_expr{{.*}}thrown_error="Never"
50+ try ? doesNotThrow ( )
51+ }
You can’t perform that action at this time.
0 commit comments