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
+107-8Lines changed: 107 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -841,6 +841,11 @@ public class TestImplicitSelfForWeakSelfCapture {
841
841
method()
842
842
self.method()
843
843
}
844
+
845
+
subscript(index: Int)-> Int { // expected-error {{subscript' functions may only be declared within a type}}
846
+
method()
847
+
return index
848
+
}
844
849
}
845
850
846
851
doVoidStuffNonEscaping{[weak self]in
@@ -855,34 +860,128 @@ public class TestImplicitSelfForWeakSelfCapture {
855
860
method()
856
861
self.method()
857
862
}
863
+
864
+
subscript(index: Int)-> Int { // expected-error {{subscript' functions may only be declared within a type}}
865
+
method()
866
+
return index
867
+
}
868
+
}
869
+
870
+
doVoidStuff{[weak self]in
871
+
guardlet self else{return}
872
+
873
+
func innerFunction1(){
874
+
doVoidStuff{ // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
875
+
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}} expected-note {{reference 'self.' explicitly}}
876
+
}
877
+
878
+
// This example should probably compile without an error -- seems like a bug in the impl of SE-0269
879
+
doVoidStuff{[self]in // expected-note {{variable other than 'self' captured here under the name 'self' does not enable implicit 'self'}}
880
+
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
881
+
self.method()
882
+
}
883
+
884
+
doVoidStuff{[weak self]in
885
+
method() // expected-error {{call to method 'method' in closure requires explicit use of 'self' to make capture semantics explicit}}
0 commit comments