Skip to content

Commit b61b68d

Browse files
authored
[AST] Look through try expressions inside open existential expression's sub expression in 'getUnwrappedCurryThunkExpr()' (#32458)
1 parent acd73a3 commit b61b68d

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
@@ -2012,7 +2012,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
20122012
body = body->getSemanticsProvidingExpr();
20132013

20142014
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(body)) {
2015-
body = openExistential->getSubExpr();
2015+
body = openExistential->getSubExpr()->getSemanticsProvidingExpr();
20162016
}
20172017

20182018
if (auto *outerCall = dyn_cast<ApplyExpr>(body)) {
@@ -2032,7 +2032,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
20322032
innerBody = innerBody->getSemanticsProvidingExpr();
20332033

20342034
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(innerBody)) {
2035-
innerBody = openExistential->getSubExpr();
2035+
innerBody = openExistential->getSubExpr()->getSemanticsProvidingExpr();
20362036
if (auto *ICE = dyn_cast<ImplicitConversionExpr>(innerBody))
20372037
innerBody = ICE->getSyntacticSubExpr();
20382038
}
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)