Skip to content

Commit e4e8078

Browse files
committed
Simplify autoclosure check in shouldOnlyWarn
1 parent 985e8d9 commit e4e8078

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,21 +2209,21 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
22092209
// unless this is something like a nonescaping closure that
22102210
// didn't have this layer of validation in Swift 5 mode.
22112211
// This doesn't apply to autoclosures.
2212-
if (auto invalidParentClosure =
2213-
parentClosureDisallowingImplicitSelf(selfDecl, ty, ACE)) {
2214-
auto invalidParentClosureExcludingOutermostCapture =
2215-
parentClosureDisallowingImplicitSelf(
2216-
selfDecl, ty, ACE, /*validateOutermostCapture:*/ false);
2217-
2218-
// In Swift 5 mode we didn't validate the outermost capture in
2219-
// nonescaping closures, so in that case we only warn.
2220-
if (!isClosureRequiringSelfQualification(ACE, Ctx) &&
2221-
(invalidParentClosureExcludingOutermostCapture !=
2222-
invalidParentClosure)) {
2223-
return true;
2224-
}
2212+
if (!isa<AutoClosureExpr>(ACE)) {
2213+
if (auto invalidParentClosure =
2214+
parentClosureDisallowingImplicitSelf(selfDecl, ty, ACE)) {
2215+
auto invalidParentClosureExcludingOutermostCapture =
2216+
parentClosureDisallowingImplicitSelf(
2217+
selfDecl, ty, ACE, /*validateOutermostCapture:*/ false);
2218+
2219+
// In Swift 5 mode we didn't validate the outermost capture in
2220+
// nonescaping closures, so in that case we only warn.
2221+
if (!isClosureRequiringSelfQualification(ACE, Ctx) &&
2222+
(invalidParentClosureExcludingOutermostCapture !=
2223+
invalidParentClosure)) {
2224+
return true;
2225+
}
22252226

2226-
if (!isa<AutoClosureExpr>(ACE)) {
22272227
return false;
22282228
}
22292229
}

0 commit comments

Comments
 (0)