File tree Expand file tree Collapse file tree 2 files changed +5
-20
lines changed Expand file tree Collapse file tree 2 files changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -1538,20 +1538,6 @@ static bool closureHasWeakSelfCapture(const AbstractClosureExpr *ACE) {
1538
1538
return false ;
1539
1539
}
1540
1540
1541
- // / Whether or not this closure with a `weak self` capture is permitted
1542
- // / to use implicit self. We can't permit this for escaping closures in
1543
- // / Swift 5 mode, because the implicit self AST in Swift 5 would cause
1544
- // / self to be captured strongly instead of weakly.
1545
- static bool
1546
- allowsImplicitSelfForWeakSelfCapture (const AbstractClosureExpr *ACE) {
1547
- if (ACE->getASTContext ().LangOpts .isSwiftVersionAtLeast (6 )) {
1548
- return true ;
1549
- }
1550
-
1551
- return AnyFunctionRef (const_cast <AbstractClosureExpr *>(ACE))
1552
- .isKnownNoEscape ();
1553
- }
1554
-
1555
1541
// / Whether or not implicit self decls in this closure require manual
1556
1542
// / lookup in order to perform diagnostics with the semantics described
1557
1543
// / in SE-0365. This is necessary for closures that capture self weakly
@@ -1654,8 +1640,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E,
1654
1640
// let self = .someOptionalVariable else { return }` or `let self =
1655
1641
// someUnrelatedVariable`. If self hasn't been unwrapped yet and is still
1656
1642
// an optional, we would have already hit an error elsewhere.
1657
- if (closureHasWeakSelfCapture (inClosure) &&
1658
- allowsImplicitSelfForWeakSelfCapture (inClosure)) {
1643
+ if (closureHasWeakSelfCapture (inClosure)) {
1659
1644
return !implicitWeakSelfReferenceIsValid (DRE, inClosure);
1660
1645
}
1661
1646
Original file line number Diff line number Diff line change @@ -749,21 +749,21 @@ public class TestImplicitSelfForWeakSelfCapture {
749
749
doVoidStuff { [ weak self] in
750
750
method ( ) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
751
751
guard let self = self else { return }
752
- method ( ) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
752
+ method ( )
753
753
}
754
754
755
755
doVoidStuff { [ weak self] in
756
756
guard let self else { return }
757
- method ( ) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
757
+ method ( )
758
758
}
759
759
760
760
doVoidStuff { [ weak self] in
761
761
if let self = self {
762
- method ( ) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
762
+ method ( )
763
763
}
764
764
765
765
if let self {
766
- method ( ) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
766
+ method ( )
767
767
}
768
768
}
769
769
You can’t perform that action at this time.
0 commit comments