@@ -1745,7 +1745,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17451745 ASTContext &ctx = inClosure->getASTContext ();
17461746
17471747 auto requiresSelfQualification =
1748- isClosureRequiringSelfQualification (inClosure, ctx );
1748+ isClosureRequiringSelfQualification (inClosure);
17491749
17501750 // Metatype self captures don't extend the lifetime of an object.
17511751 if (captureType->is <MetatypeType>()) {
@@ -1783,7 +1783,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17831783 // that defines self if present.
17841784 if (validateSelfRebindings) {
17851785 if (auto conditionalStmt = parentConditionalStmt (selfDecl)) {
1786- if (!hasValidSelfRebinding (conditionalStmt, inClosure )) {
1786+ if (!hasValidSelfRebinding (conditionalStmt, ctx )) {
17871787 return false ;
17881788 }
17891789 }
@@ -1793,7 +1793,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
17931793 // closure unwraps self. If not, implicit self is not allowed
17941794 // in this closure or in any nested closure.
17951795 if (closureHasWeakSelfCapture (inClosure) &&
1796- !hasValidSelfRebinding (parentConditionalStmt (selfDecl), inClosure )) {
1796+ !hasValidSelfRebinding (parentConditionalStmt (selfDecl), ctx )) {
17971797 return false ;
17981798 }
17991799
@@ -1967,7 +1967,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
19671967
19681968 static bool
19691969 hasValidSelfRebinding (const LabeledConditionalStmt *conditionalStmt,
1970- const AbstractClosureExpr *inClosure ) {
1970+ ASTContext &ctx ) {
19711971 if (!conditionalStmt) {
19721972 return false ;
19731973 }
@@ -1980,8 +1980,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
19801980 // guard let self = self else { return }
19811981 // method() // <- implicit self is not allowed
19821982 //
1983- return conditionalStmt->rebindsSelf (inClosure->getASTContext (),
1984- /* requiresCaptureListRef*/ true );
1983+ return conditionalStmt->rebindsSelf (ctx, /* requiresCaptureListRef*/ true );
19851984 }
19861985
19871986 // / The `LabeledConditionalStmt` that contains the given `ValueDecl` if
@@ -2064,8 +2063,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
20642063 // / Return true if this is a closure expression that will require explicit
20652064 // / use or capture of "self." for qualification of member references.
20662065 static bool
2067- isClosureRequiringSelfQualification (const AbstractClosureExpr *CE,
2068- ASTContext &Ctx) {
2066+ isClosureRequiringSelfQualification (const AbstractClosureExpr *CE) {
20692067 if (closureHasWeakSelfCapture (CE)) {
20702068 return true ;
20712069 }
@@ -2245,7 +2243,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
22452243 // to use implicit self, even after fixing any invalid parents.
22462244 auto isEscapingAutoclosure =
22472245 isa<AutoClosureExpr>(ACE) &&
2248- isClosureRequiringSelfQualification (ACE, Ctx );
2246+ isClosureRequiringSelfQualification (ACE);
22492247 if (!isEscapingAutoclosure) {
22502248 closureForDiagnostics = parentDisallowingImplicitSelf;
22512249 }
@@ -2382,7 +2380,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
23822380 return true ;
23832381 }
23842382
2385- if (isUsageAlwaysPreviouslyRejected (selfDecl, ACE )) {
2383+ if (isUsageAlwaysPreviouslyRejected (selfDecl)) {
23862384 return false ;
23872385 }
23882386
@@ -2429,7 +2427,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
24292427 }
24302428
24312429 if (auto condStmt = parentConditionalStmt (selfDecl)) {
2432- auto isValidSelfRebinding = hasValidSelfRebinding (condStmt, ACE );
2430+ auto isValidSelfRebinding = hasValidSelfRebinding (condStmt, Ctx );
24332431
24342432 // Swfit 5.8 permitted implicit self without validating any
24352433 // parent closures. If implicit self is only disallowed due to
@@ -2443,8 +2441,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
24432441 // If the binding is valid when only checking for a load expr,
24442442 // then we must only warn.
24452443 auto usesLoadExpr =
2446- condStmt->rebindsSelf (ACE->getASTContext (),
2447- /* requiresCaptureListRef*/ false ,
2444+ condStmt->rebindsSelf (Ctx, /* requiresCaptureListRef*/ false ,
24482445 /* requireLoadExpr*/ true );
24492446
24502447 if (!isValidSelfRebinding && usesLoadExpr) {
@@ -2457,12 +2454,11 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
24572454
24582455 // / Checks if this implicit self usage was always previously rejected as
24592456 // / invalid, so can continue to be treated an error.
2460- bool isUsageAlwaysPreviouslyRejected (ValueDecl *selfDecl,
2461- AbstractClosureExpr *ACE) {
2457+ bool isUsageAlwaysPreviouslyRejected (ValueDecl *selfDecl) {
24622458 // If the self decl refers to a weak self unwrap condition
24632459 // in some parent closure, then there is no source-compatibility
24642460 // requirement to avoid an error.
2465- return hasValidSelfRebinding (parentConditionalStmt (selfDecl), ACE );
2461+ return hasValidSelfRebinding (parentConditionalStmt (selfDecl), Ctx );
24662462 }
24672463
24682464 // / Checks if this is a usage of implicit self in a strong self closure
@@ -2499,7 +2495,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
24992495 if (DC->isLocalContext ()) {
25002496 while (DC->getParent ()->isLocalContext () && !ACE) {
25012497 if (auto *closure = dyn_cast<AbstractClosureExpr>(DC))
2502- if (DiagnoseWalker::isClosureRequiringSelfQualification (closure, ctx ))
2498+ if (DiagnoseWalker::isClosureRequiringSelfQualification (closure))
25032499 ACE = const_cast <AbstractClosureExpr *>(closure);
25042500 DC = DC->getParent ();
25052501 }
0 commit comments