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
[Concurrency] Diagnose loss of global actor isolation in async function conversions
Perform `Sendable` checking on parameter/result of the function
type when conversion between asynchroneous functions results in
a loss of global actor isolation attribute because access would
result in data crossing an isolation boundary.
This is a warning until Swift language mode 6.
Resolves: rdar://130168104
(cherry picked from commit a058ffc)
let _: nonisolated(nonsending)()async->NonSendable= globalActor2 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
118
118
// expected-error@-1 {{cannot convert '@MainActor @Sendable () async -> NonSendable' to 'nonisolated(nonsending) () async -> NonSendable' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
119
119
120
+
let _:@concurrent(NonSendable)async->Void= globalActor1 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
121
+
// expected-warning@-1 {{cannot convert '@MainActor @Sendable (NonSendable) async -> Void' to '(NonSendable) async -> Void' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
122
+
let _:@concurrent()async->NonSendable= globalActor2 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
123
+
// expected-warning@-1 {{cannot convert '@MainActor @Sendable () async -> NonSendable' to '() async -> NonSendable' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
124
+
120
125
let _: nonisolated(nonsending)(NonSendable)async->Void= erased1 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
121
126
// expected-error@-1 {{cannot convert '@isolated(any) @Sendable (NonSendable) async -> Void' to 'nonisolated(nonsending) (NonSendable) async -> Void' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
122
127
let _: nonisolated(nonsending)()async->NonSendable= erased2 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
// expected-error@-1 {{cannot convert '@MainActor @Sendable () async -> NonSendable' to '() async -> NonSendable' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
13
+
// expected-note@-2 {{type 'NonSendable' does not conform to 'Sendable' protocol}}
0 commit comments