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
[Sema]: ban @isolated(any) conversions to synchronous function types
per SE-0431, function conversions from an @isolated(any) function to a synchronous,
non-@isolated(any) function type should not be allowed. this adds a warning during
type checking to enforce this, which will be an error in a future major
language mode.
(cherry picked from commit 629e208)
// expected-warning @+1 {{converting @isolated(any) function of type '@isolated(any) @Sendable () -> ()' to synchronous function type '@Sendable () -> ()' is not allowed; this will be an error in a future Swift language mode}}
// expected-warning @+1 {{converting @isolated(any) function of type '@isolated(any) () -> ()' to synchronous function type '() -> ()' is not allowed; this will be an error in a future Swift language mode}}
_ fn:@escaping@isolated(any)()->Void // expected-note {{parameter 'fn' is implicitly non-sendable}}
130
142
){
131
143
let _:@Sendable()->Void= fn // expected-warning {{using non-sendable parameter 'fn' in a context expecting a '@Sendable' closure}}
144
+
// expected-warning @-1 {{converting @isolated(any) function of type '@isolated(any) () -> Void' to synchronous function type '@Sendable () -> Void' is not allowed; this will be an error in a future Swift language mode}}
145
+
}
146
+
147
+
func nonSendableIsolatedAnyAsyncToSendableSync(
148
+
_ fn:@escaping@isolated(any)()async->Void // expected-note {{parameter 'fn' is implicitly non-sendable}}
149
+
){
150
+
let _:@Sendable()->Void= fn // expected-warning {{using non-sendable parameter 'fn' in a context expecting a '@Sendable' closure}}
151
+
// expected-error @-1 {{invalid conversion from 'async' function of type '@isolated(any) () async -> Void' to synchronous function type '@Sendable () -> Void'}}
152
+
}
153
+
154
+
func nonSendableIsolatedAnyAsyncToSendableAsync(
155
+
_ fn:@escaping@isolated(any)()async->Void // expected-note {{parameter 'fn' is implicitly non-sendable}}
156
+
){
157
+
let _:@Sendable()async->Void= fn // expected-warning {{using non-sendable parameter 'fn' in a context expecting a '@Sendable' closure}}
0 commit comments