Skip to content

Commit bdbe062

Browse files
committed
Sema: Tweak SanitizeExpr handling of AutoClosureExprs
Curry thunks create AutoClosureExprs with parameters, and we can't just fold those away. Also, remove an older AutoClosureExpr cleanup that seems to be redundant.
1 parent e47543c commit bdbe062

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3409,8 +3409,11 @@ namespace {
34093409

34103410
// Restore '@autoclosure'd value.
34113411
if (auto ACE = dyn_cast<AutoClosureExpr>(expr)) {
3412-
expr = ACE->getSingleExpressionBody();
3413-
continue;
3412+
// This is only valid if the closure doesn't have parameters.
3413+
if (ACE->getParameters()->size() == 0) {
3414+
expr = ACE->getSingleExpressionBody();
3415+
continue;
3416+
}
34143417
}
34153418

34163419
// Remove any semantic expression injected by typechecking.

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,13 +1229,6 @@ namespace {
12291229
DC = ce->getParent();
12301230
}
12311231

1232-
// Strip off any AutoClosures that were produced by a previous type check
1233-
// so that we don't choke in CSGen.
1234-
// FIXME: we shouldn't double typecheck, but it looks like code completion
1235-
// may do so in some circumstances. rdar://21466394
1236-
if (auto autoClosure = dyn_cast<AutoClosureExpr>(expr))
1237-
return autoClosure->getSingleExpressionBody();
1238-
12391232
// A 'self.init' or 'super.init' application inside a constructor will
12401233
// evaluate to void, with the initializer's result implicitly rebound
12411234
// to 'self'. Recognize the unresolved constructor expression and

0 commit comments

Comments
 (0)