@@ -2468,6 +2468,15 @@ namespace {
2468
2468
// If the closure won't execute concurrently with the context in
2469
2469
// which the declaration occurred, it's okay.
2470
2470
auto decl = capture.getDecl ();
2471
+ auto isolation = getActorIsolation (decl);
2472
+
2473
+ // 'nonisolated' local variables are always okay to capture in
2474
+ // 'Sendable' closures because they can be accessed from anywhere.
2475
+ // Note that only 'nonisolated(unsafe)' can be applied to local
2476
+ // variables.
2477
+ if (isolation.isNonisolated ())
2478
+ continue ;
2479
+
2471
2480
auto *context = localFunc.getAsDeclContext ();
2472
2481
auto fnType = localFunc.getType ()->getAs <AnyFunctionType>();
2473
2482
if (!mayExecuteConcurrentlyWith (context, decl->getDeclContext ()))
@@ -5490,13 +5499,18 @@ static bool checkSendableInstanceStorage(
5490
5499
5491
5500
// / Handle a stored property.
5492
5501
bool operator ()(VarDecl *property, Type propertyType) override {
5502
+ ActorIsolation isolation = getActorIsolation (property);
5503
+
5504
+ // 'nonisolated' properties are always okay in 'Sendable' types because
5505
+ // they can be accessed from anywhere. Note that 'nonisolated' without
5506
+ // '(unsafe)' can only be applied to immutable, 'Sendable' properties.
5507
+ if (isolation.isNonisolated ())
5508
+ return false ;
5509
+
5493
5510
// Classes with mutable properties are Sendable if property is
5494
5511
// actor-isolated
5495
5512
if (isa<ClassDecl>(nominal)) {
5496
- ActorIsolation isolation = getActorIsolation (property);
5497
-
5498
- if (property->supportsMutation () &&
5499
- (isolation.isNonisolated () || isolation.isUnspecified ())) {
5513
+ if (property->supportsMutation () && isolation.isUnspecified ()) {
5500
5514
auto behavior =
5501
5515
SendableCheckContext (dc, check).defaultDiagnosticBehavior ();
5502
5516
if (behavior != DiagnosticBehavior::Ignore) {
0 commit comments