Skip to content

Commit 0b02d61

Browse files
committed
Sema: Simplify applyTypeToClosureExpr()
1 parent 43fd786 commit 0b02d61

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5777,16 +5777,9 @@ Expr *ExprRewriter::coerceCallArguments(Expr *arg, AnyFunctionType *funcType,
57775777
return cs.cacheType(arg);
57785778
}
57795779

5780-
static ClosureExpr *getClosureLiteralExpr(Expr *expr) {
5780+
static bool isClosureLiteralExpr(Expr *expr) {
57815781
expr = expr->getSemanticsProvidingExpr();
5782-
5783-
if (auto *captureList = dyn_cast<CaptureListExpr>(expr))
5784-
return captureList->getClosureBody();
5785-
5786-
if (auto *closure = dyn_cast<ClosureExpr>(expr))
5787-
return closure;
5788-
5789-
return nullptr;
5782+
return (isa<CaptureListExpr>(expr) || isa<ClosureExpr>(expr));
57905783
}
57915784

57925785
/// If the expression is an explicit closure expression (potentially wrapped in
@@ -7329,7 +7322,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
73297322
}
73307323

73317324
// An immediate application of a closure literal is always noescape.
7332-
if (getClosureLiteralExpr(fn)) {
7325+
if (isClosureLiteralExpr(fn)) {
73337326
if (auto fnTy = cs.getType(fn)->getAs<FunctionType>()) {
73347327
fnTy = cast<FunctionType>(
73357328
fnTy->withExtInfo(fnTy->getExtInfo().withNoEscape()));

0 commit comments

Comments
 (0)