mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Make sure we record "Never" as the thrown error type for try!/try?
This commit is contained in:
@@ -3104,6 +3104,8 @@ private:
|
||||
|
||||
if (auto thrownError = TypeChecker::canThrow(Ctx, E->getSubExpr())) {
|
||||
E->setThrownError(*thrownError);
|
||||
} else {
|
||||
E->setThrownError(Ctx.getNeverType());
|
||||
}
|
||||
|
||||
scope.preserveCoverageFromOptionalOrForcedTryOperand();
|
||||
@@ -3123,6 +3125,8 @@ private:
|
||||
|
||||
if (auto thrownError = TypeChecker::canThrow(Ctx, E->getSubExpr())) {
|
||||
E->setThrownError(*thrownError);
|
||||
} else {
|
||||
E->setThrownError(Ctx.getNeverType());
|
||||
}
|
||||
|
||||
scope.preserveCoverageFromOptionalOrForcedTryOperand();
|
||||
|
||||
@@ -37,3 +37,15 @@ func throwsAnything() throws {
|
||||
// CHECK: optional_try_expr{{.*}}thrown_error="MyError"
|
||||
try? printOrFail("ssshhhhh")
|
||||
}
|
||||
|
||||
func doesNotThrow() { }
|
||||
|
||||
func throwsNothing() {
|
||||
// CHECK-LABE: func_decl{{.*}}"throwsNothing()"
|
||||
|
||||
// CHECK: force_try_expr{{.*}}thrown_error="Never"
|
||||
try! doesNotThrow()
|
||||
|
||||
// CHECK: optional_try_expr{{.*}}thrown_error="Never"
|
||||
try? doesNotThrow()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user