You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revert "Remove properties from AST nodes"
This reverts commit e4b8a82.
Revert "Suppress more false-positive 'self is unused' warnings"
This reverts commit 35e028e.
Revert "fix warning annotation in test"
This reverts commit dfa1fda.
Revert "Permit implicit self for weak self captures in nonescaping closures in Swift 5 (this is an error in Swift 6)"
This reverts commit 94ef6c4.
Copy file name to clipboardExpand all lines: test/expr/closure/closures.swift
+17-17Lines changed: 17 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -176,8 +176,8 @@ class ExplicitSelfRequiredTest {
176
176
doVoidStuff({ _ ="\(x)"}) // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{18-18= [self] in}} expected-note{{reference 'self.' explicitly}} {{26-26=self.}}
177
177
doVoidStuff({[y =self]in x +=1}) // expected-warning {{capture 'y' was never used}} expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{20-20=self, }} expected-note{{reference 'self.' explicitly}} {{33-33=self.}}
178
178
doStuff({[y =self]in x+1}) // expected-warning {{capture 'y' was never used}} expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{16-16=self, }} expected-note{{reference 'self.' explicitly}} {{29-29=self.}}
179
-
doVoidStuff({[self=ExplicitSelfRequiredTest()]in x +=1}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
180
-
doStuff({[self=ExplicitSelfRequiredTest()]in x+1}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
179
+
doVoidStuff({[self=ExplicitSelfRequiredTest()]in x +=1}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{capture 'self' was never used}}
180
+
doStuff({[self=ExplicitSelfRequiredTest()]in x+1}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{capture 'self' was never used}}
181
181
182
182
// Methods follow the same rules as properties, uses of 'self' without capturing must be marked with "self."
183
183
doStuff{method()} // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{14-14= [self] in}} expected-note{{reference 'self.' explicitly}} {{15-15=self.}}
@@ -186,8 +186,8 @@ class ExplicitSelfRequiredTest {
186
186
doVoidStuff{()->()in _ =method()} // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{18-18= [self]}} expected-note{{reference 'self.' explicitly}} {{35-35=self.}}
187
187
doVoidStuff{[y =self]in _ =method()} // expected-warning {{capture 'y' was never used}} expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{20-20=self, }} expected-note{{reference 'self.' explicitly}} {{37-37=self.}}
188
188
doStuff({[y =self]inmethod()}) // expected-warning {{capture 'y' was never used}} expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note{{capture 'self' explicitly to enable implicit 'self' in this closure}} {{16-16=self, }} expected-note{{reference 'self.' explicitly}} {{29-29=self.}}
189
-
doVoidStuff({[self=ExplicitSelfRequiredTest()]in _ =method()}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
190
-
doStuff({[self=ExplicitSelfRequiredTest()]inmethod()}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
189
+
doVoidStuff({[self=ExplicitSelfRequiredTest()]in _ =method()}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{capture 'self' was never used}}
190
+
doStuff({[self=ExplicitSelfRequiredTest()]inmethod()}) // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}} expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{capture 'self' was never used}}
191
191
doVoidStuff{ _ =self.method()}
192
192
doVoidStuff{[self]in _ =method()}
193
193
doVoidStuff{[self=self]in _ =method()}
@@ -261,12 +261,12 @@ class ExplicitSelfRequiredTest {
261
261
// because its `sawError` flag is set to true. To preserve the "capture 'y' was never used" warnings
262
262
// above, we put these cases in their own method.
263
263
func weakSelfError(){
264
-
doVoidStuff({[weak self]in x +=1}) // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
265
-
doVoidStuffNonEscaping({[weak self]in x +=1}) // expected-warning {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
266
-
doStuff({[weak self]in x+1}) // expected-error {{reference to property 'x' in closure requires explicit use of 'self' to make capture semantics explicit}}
267
-
doVoidStuff({[weak self]in _ =method()}) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
268
-
doVoidStuffNonEscaping({[weak self]in _ =method()}) // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
269
-
doStuff({[weak self]inmethod()}) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
264
+
doVoidStuff({[weak self]in x +=1}) // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
265
+
doVoidStuffNonEscaping({[weak self]in x +=1}) // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
266
+
doStuff({[weak self]in x+1}) // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
267
+
doVoidStuff({[weak self]in _ =method()}) // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note{{reference 'self?.' explicitly}}
268
+
doVoidStuffNonEscaping({[weak self]in _ =method()}) // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note{{reference 'self?.' explicitly}}
269
+
doStuff({[weak self]inmethod()}) // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note{{reference 'self?.' explicitly}}
270
270
}
271
271
}
272
272
@@ -742,12 +742,12 @@ public class TestImplicitCaptureOfExplicitCaptureOfSelfInEscapingClosure {
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
750
+
method() // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
751
751
guardlet self =selfelse{return}
752
752
method()
753
753
}
@@ -771,7 +771,7 @@ public class TestImplicitSelfForWeakSelfCapture {
771
771
}
772
772
773
773
doVoidStuffNonEscaping{[weak self]in
774
-
method() // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
774
+
method() // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
775
775
guardlet self =selfelse{return}
776
776
method()
777
777
}
@@ -791,7 +791,7 @@ public class TestImplicitSelfForWeakSelfCapture {
0 commit comments