Skip to content

Commit 917eacb

Browse files
authored
Merge pull request #71197 from hborla/isolated-parameter-sendable
2 parents d935c53 + fef9a54 commit 917eacb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/Sema/TypeCheckConcurrency.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3307,6 +3307,7 @@ namespace {
33073307
KnownProtocolKind::Actor);
33083308
}
33093309

3310+
mayExitToNonisolated = false;
33103311
auto calleeIsolation = ActorIsolation::forActorInstanceParameter(
33113312
const_cast<Expr *>(arg->findOriginalValue()), paramIdx);
33123313

test/Concurrency/isolated_parameters.swift

+13-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ nonisolated func callFromNonisolated(ns: NotSendable) async {
393393
let myActor = A()
394394

395395
await optionalIsolated(ns, to: myActor)
396-
// expected-complete-warning@-1 {{passing argument of non-sendable type 'NotSendable' outside of main actor-isolated context may introduce data races}}
396+
// expected-complete-warning@-1 {{passing argument of non-sendable type 'NotSendable' into actor-isolated context may introduce data races}}
397397

398398
optionalIsolatedSync(ns, to: myActor)
399399
// expected-error@-1 {{expression is 'async' but is not marked with 'await'}}
@@ -439,6 +439,10 @@ func testNonSendableCaptures(ns: NotSendable, a: isolated MyActor) {
439439

440440
func sync(isolatedTo actor: isolated (any Actor)?) {}
441441

442+
func pass(value: NotSendable, isolation: isolated (any Actor)?) async -> NotSendable {
443+
value
444+
}
445+
442446
func preciseIsolated(a: isolated MyActor) async {
443447
sync(isolatedTo: a)
444448
sync(isolatedTo: nil) // okay from anywhere
@@ -461,3 +465,11 @@ func preciseIsolated(a: isolated MyActor) async {
461465
sync(isolatedTo: #isolation)
462466
}
463467
}
468+
469+
@MainActor func fromMain(ns: NotSendable) async -> NotSendable {
470+
await pass(value: ns, isolation: MainActor.shared)
471+
}
472+
473+
nonisolated func fromNonisolated(ns: NotSendable) async -> NotSendable {
474+
await pass(value: ns, isolation: nil)
475+
}

0 commit comments

Comments
 (0)