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] Skip Sendable checking for nonisolated(nonsending) -> @concurrent conversions
Converting a `nonisolated(nonsending)` function type to a
`@concurrent` one is the same as converting it to an actor-isolated
function type. `nonisolated(nonsending)` functions run on the
caller's actor without crossing an isolation boundary and so
no Sendable checking is necessary.
Resolves: swiftlang#87235
Resolves: rdar://170380869
(cherry picked from commit 5f9efd2)
// expected-warning@-1 {{cannot convert '@isolated(any) @Sendable () async -> NonSendable' to '() async -> NonSendable' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
142
142
143
143
144
-
let _:@concurrent(NonSendable)async->Void= caller1 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
145
-
// expected-warning@-1 {{cannot convert 'nonisolated(nonsending) @Sendable (NonSendable) async -> Void' to '(NonSendable) async -> Void' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
146
-
let _:@concurrent()async->NonSendable= caller2 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
147
-
// expected-warning@-1 {{cannot convert 'nonisolated(nonsending) @Sendable () async -> NonSendable' to '() async -> NonSendable' because crossing of an isolation boundary requires parameter and result types to conform to 'Sendable' protocol}}
144
+
// Calling `nonisolated(nonsending)` from `@concurrent` doesn't cross an isolation boundary.
145
+
let _:@concurrent(NonSendable)async->Void= caller1 // Ok
146
+
let _:@concurrent()async->NonSendable= caller2 // Ok
148
147
149
148
let _:@MainActor(NonSendable)async->Void= nonIsolated1 // Ok
150
149
let _:@MainActor(NonSendable)async->Void= nonIsolated2 // expected-note {{type 'NonSendable' does not conform to 'Sendable' protocol}}
0 commit comments