Skip to content

Commit 5f803ee

Browse files
authored
Merge pull request #34131 from MaxDesiatov/maxd/fix-SR-12994
AST: Fix assertions crash with try expressions (main branch cherry-pick)
2 parents 9348907 + fd4b01f commit 5f803ee

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/AST/Expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
19431943
body = body->getSemanticsProvidingExpr();
19441944

19451945
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(body)) {
1946-
body = openExistential->getSubExpr();
1946+
body = openExistential->getSubExpr()->getSemanticsProvidingExpr();
19471947
}
19481948

19491949
if (auto *outerCall = dyn_cast<ApplyExpr>(body)) {
@@ -1963,7 +1963,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
19631963
innerBody = innerBody->getSemanticsProvidingExpr();
19641964

19651965
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(innerBody)) {
1966-
innerBody = openExistential->getSubExpr();
1966+
innerBody = openExistential->getSubExpr()->getSemanticsProvidingExpr();
19671967
if (auto *ICE = dyn_cast<ImplicitConversionExpr>(innerBody))
19681968
innerBody = ICE->getSyntacticSubExpr();
19691969
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s -verify
3+
4+
protocol MyProto {
5+
func compile() throws
6+
}
7+
8+
func compile(x: MyProto) throws {
9+
try x.compile
10+
// expected-error@-1 {{expression resolves to an unused function}}
11+
// expected-warning@-2 {{no calls to throwing functions occur within 'try' expression}}
12+
}

0 commit comments

Comments
 (0)