File tree Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -4005,7 +4005,7 @@ VarDeclUsageChecker::~VarDeclUsageChecker() {
4005
4005
4006
4006
// If this variable has WeakStorageType, then it can be mutated in ways we
4007
4007
// don't know.
4008
- if (var->getInterfaceType ()->is <WeakStorageType>())
4008
+ if (var->getInterfaceType ()->is <WeakStorageType>() && !DC-> getASTContext (). LangOpts . hasFeature (Feature::WeakLet) )
4009
4009
access |= RK_Written;
4010
4010
4011
4011
// Diagnose variables that were never used (other than their
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ final class CheckSendability12: Sendable {
110
110
111
111
112
112
func checkWeakCapture1( _ strongRef: S ) -> @Sendable ( ) -> Void {
113
+ // expected-new-warning@+1 {{variable 'weakRef' was never mutated; consider changing to 'let' constant}}
113
114
weak var weakRef : S ? = strongRef
114
115
return {
115
116
// expected-old-error@+2 {{reference to captured var 'weakRef' in concurrently-executing code}}
@@ -137,7 +138,7 @@ func checkWeakCapture3(_ strongRef: S) -> @Sendable () -> Void {
137
138
}
138
139
139
140
func checkWeakCapture4( _ strongRef: NS ) -> @Sendable ( ) -> Void {
140
- // TODO: warning consider changing to 'let' constant
141
+ // expected-new- warning@+1 {{variable 'weakRef' was never mutated; consider changing to 'let' constant}}
141
142
weak var weakRef : NS ? = strongRef
142
143
return {
143
144
// expected-old-error@+4 {{capture of 'weakRef' with non-sendable type 'NS?' in a '@Sendable' closure}}
You can’t perform that action at this time.
0 commit comments