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() {
40054005
40064006 // If this variable has WeakStorageType, then it can be mutated in ways we
40074007 // don't know.
4008- if (var->getInterfaceType ()->is <WeakStorageType>())
4008+ if (var->getInterfaceType ()->is <WeakStorageType>() && !DC-> getASTContext (). LangOpts . hasFeature (Feature::WeakLet) )
40094009 access |= RK_Written;
40104010
40114011 // 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 {
110110
111111
112112func checkWeakCapture1( _ strongRef: S ) -> @Sendable ( ) -> Void {
113+ // expected-new-warning@+1 {{variable 'weakRef' was never mutated; consider changing to 'let' constant}}
113114 weak var weakRef : S ? = strongRef
114115 return {
115116 // expected-old-error@+2 {{reference to captured var 'weakRef' in concurrently-executing code}}
@@ -137,7 +138,7 @@ func checkWeakCapture3(_ strongRef: S) -> @Sendable () -> Void {
137138}
138139
139140func 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}}
141142 weak var weakRef : NS ? = strongRef
142143 return {
143144 // 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