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
varstored:Optional<(()->Int)->Void>=nil // expected-note {{add explicit @escaping to function parameter #0}} {{26-26=@escaping }}
150
150
varcomputed:(()->Int)->Void{
151
151
get{return stored! }
152
152
set(newValue){ stored = newValue } // ok
153
153
}
154
154
varcomputedEscaping:(@escaping()->Int)->Void{
155
155
get{return stored! }
156
-
set(newValue){ stored = newValue } // expected-error{{assigning non-escaping parameter 'newValue' to an @escaping closure}}
157
-
// expected-note@-1 {{parameter 'newValue' is implicitly non-escaping}}
156
+
set(newValue){ stored = newValue } // expected-error{{converting escaping to non-escaping functions of type '() -> Int' in parameter position #0 of function type member 'stored' is not allowed}}
158
157
}
159
158
}
160
159
@@ -230,3 +229,29 @@ extension SR_9760 {
230
229
231
230
// SR-9178
232
231
func foo<T>(_ x:@escapingT){} // expected-error 1{{@escaping attribute only applies to function types}}
232
+
233
+
// SR-14720
234
+
classSR14720{
235
+
letok:(@escaping()->Void)->Void // OK
236
+
letcallback:(()->Void)->Void // expected-note {{add explicit @escaping to function parameter #0}} {{18-18=@escaping }}
237
+
letcallback1:(()->Void,()->Void)->Void // expected-note {{add explicit @escaping to function parameter #1}} {{31-31=@escaping }}
238
+
letcallbackAuto:(@autoclosure()->Void)->Void // expected-note {{add explicit @escaping to function parameter #0}} {{34-34= @escaping}}
239
+
letcallbackOpt:((()->Void)->Void)? // expected-note{{add explicit @escaping to function parameter #0}} {{22-22=@escaping }}
240
+
241
+
init(f:@escaping(@escaping()->Void)->Void){
242
+
self.callback = f // expected-error{{converting escaping to non-escaping functions of type '() -> Void' in parameter position #0 of function type member 'callback' is not allowed}}
243
+
self.ok = f // Ok
244
+
}
245
+
246
+
init(af:@escaping(@escaping()->Void)->Void){
247
+
self.callbackOpt = af // expected-error{{converting escaping to non-escaping functions of type '() -> Void' in parameter position #0 of function type member 'callbackOpt' is not allowed}}
248
+
}
249
+
250
+
init(a:@escaping(@escaping()->Void)->Void){
251
+
self.callbackAuto = a // expected-error{{converting escaping to non-escaping functions of type '() -> Void' in parameter position #0 of function type member 'callbackAuto' is not allowed}}
self.callback1 = f // expected-error{{converting escaping to non-escaping functions of type '() -> Void' in parameter position #1 of function type member 'callback1' is not allowed}}
0 commit comments