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
Copy file name to clipboardExpand all lines: test/expr/closure/closures.swift
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -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 {{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}}
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}} expected-warning {{variable 'self' was written to, but never read}}
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}} expected-warning {{variable 'self' was written to, but never read}}
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}} expected-warning {{variable 'self' was written to, but never read}}
267
+
doVoidStuff({[weak self]in _ =method()}) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{variable 'self' was written to, but never read}}
268
+
doVoidStuffNonEscaping({[weak self]in _ =method()}) // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{variable 'self' was written to, but never read}}
269
+
doStuff({[weak self]inmethod()}) // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-warning {{variable 'self' was written to, but never read}}
270
270
}
271
271
}
272
272
@@ -742,12 +742,12 @@ public class TestImplicitCaptureOfExplicitCaptureOfSelfInEscapingClosure {
method() // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
750
+
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
751
751
guardlet self =selfelse{return}
752
752
method()
753
753
}
@@ -759,19 +759,19 @@ public class TestImplicitSelfForWeakSelfCapture {
759
759
}
760
760
761
761
doVoidStuff{[weak self]in
762
-
guardlet self =selfelse{return}
762
+
guardlet self =selfelse{return} // expected-warning {{value 'self' was defined but never used; consider replacing with boolean test}}
763
763
doVoidStuff{ // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
764
764
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
guardlet self =self??TestImplicitSelfForWeakSelfCapture.staticOptional else{return} // expected-warning {{value 'self' was defined but never used; consider replacing with boolean test}}
770
770
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
771
771
}
772
772
773
773
doVoidStuffNonEscaping{[weak self]in
774
-
method() // expected-error {{explicit use of 'self' is required when 'self' is optional, to make control flow explicit}} expected-note {{reference 'self?.' explicitly}}
774
+
method() // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
775
775
guardlet self =selfelse{return}
776
776
method()
777
777
}
@@ -784,26 +784,26 @@ public class TestImplicitSelfForWeakSelfCapture {
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
793
+
guardlet self =selfelse{return} // expected-warning {{unexpected warning produced: value 'self' was defined but never used; consider replacing with boolean test}}
794
+
method() // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
795
795
}
796
796
797
797
doVoidStuffNonEscaping{[weak self]in
798
-
guardlet self =selfelse{return}
798
+
guardlet self =selfelse{return} // expected-warning {{unexpected warning produced: value 'self' was defined but never used; consider replacing with boolean test}}
799
799
doVoidStuff{ // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
800
800
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
805
+
guardlet self =self??TestImplicitSelfForWeakSelfCapture.staticOptional else{return} // expected-warning {{unexpected warning produced: value 'self' was defined but never used; consider replacing with boolean test}}
806
+
method() // expected-warning {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
807
807
}
808
808
}
809
809
}
@@ -824,12 +824,12 @@ public class TestRebindingSelfIsDisallowed {
824
824
825
825
doVoidStuff{[weak self]in
826
826
let`self`="self shouldn't become a string"
827
-
let _:Int= count // expected-error{{reference to property 'count' in closure requires explicit use of 'self' to make capture semantics explicit}}
827
+
let _:Int= count // expected-error{{cannot convert value of type 'Void' to specified type 'Int'}}
828
828
}
829
829
830
830
doVoidStuffNonEscaping{[weak self]in
831
831
let`self`="self shouldn't become a string"
832
-
let _:Int= count // expected-error{{reference to property 'count' in closure requires explicit use of 'self' to make capture semantics explicit}}
832
+
let _:Int= count // expected-error{{cannot convert value of type 'Void' to specified type 'Int'}}
0 commit comments