Skip to content

Commit e7ee53b

Browse files
authored
Merge pull request #17622 from DougGregor/fix-optional-rethrows-checking
[Type checker] Look through optionals when checking for rethrows.
2 parents f9ab5c8 + 932e9be commit e7ee53b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Sema/TypeCheckError.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ class AbstractFunction {
134134
fn = conversion->getSubExpr()->getValueProvidingExpr();
135135
} else if (auto conversion = dyn_cast<BindOptionalExpr>(fn)) {
136136
fn = conversion->getSubExpr()->getValueProvidingExpr();
137+
// Look through optional injections
138+
} else if (auto injection = dyn_cast<InjectIntoOptionalExpr>(fn)) {
139+
fn = injection->getSubExpr()->getValueProvidingExpr();
137140
// Look through function conversions.
138141
} else if (auto conversion = dyn_cast<FunctionConversionExpr>(fn)) {
139142
fn = conversion->getSubExpr()->getValueProvidingExpr();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// Used to crash with: apply expression is not marked as throwing or
4+
// non-throwing
5+
struct SR5427 : Error {}
6+
func sr5427(op: (() throws -> Void)?) rethrows { try op?() }
7+
try? sr5427(op: { throw SR5427() })

0 commit comments

Comments
 (0)