@@ -428,9 +428,19 @@ ActorIsolationRestriction ActorIsolationRestriction::forDeclaration(
428
428
// nonisolated, they need cross-actor restrictions (e.g., for Sendable).
429
429
if (auto *ctor = dyn_cast<ConstructorDecl>(decl))
430
430
if (!ctor->isConvenienceInit ())
431
- if (auto *parent = dyn_cast<ClassDecl>(ctor->getParent ()))
432
- if (parent->isAnyActor ())
433
- return forActorSelf (parent, /* isCrossActor=*/ true );
431
+ if (auto *parent = ctor->getParent ()->getSelfClassDecl ())
432
+ if (parent->isAnyActor ())
433
+ return forActorSelf (parent, /* isCrossActor=*/ true );
434
+
435
+ // `nonisolated let` members are cross-actor as well.
436
+ if (auto var = dyn_cast<VarDecl>(decl)) {
437
+ if (var->isInstanceMember () && var->isLet ()) {
438
+ if (auto parent = var->getDeclContext ()->getSelfClassDecl ()) {
439
+ if (parent->isActor () && !parent->isDistributedActor ())
440
+ return forActorSelf (parent, /* isCrossActor=*/ true );
441
+ }
442
+ }
443
+ }
434
444
435
445
return forUnrestricted ();
436
446
@@ -3214,18 +3224,6 @@ ActorIsolation ActorIsolationRequest::evaluate(
3214
3224
// If this declaration has one of the actor isolation attributes, report
3215
3225
// that.
3216
3226
if (isolationFromAttr) {
3217
- // Nonisolated declarations must involve Sendable types.
3218
- if (*isolationFromAttr == ActorIsolation::Independent) {
3219
- SubstitutionMap subs;
3220
- if (auto genericEnv = value->getInnermostDeclContext ()
3221
- ->getGenericEnvironmentOfContext ()) {
3222
- subs = genericEnv->getForwardingSubstitutionMap ();
3223
- }
3224
- diagnoseNonSendableTypesInReference (
3225
- ConcreteDeclRef (value, subs), value->getDeclContext (),
3226
- value->getLoc (), ConcurrentReferenceKind::Nonisolated);
3227
- }
3228
-
3229
3227
// Classes with global actors have additional rules regarding inheritance.
3230
3228
if (isolationFromAttr->isGlobalActor ()) {
3231
3229
if (auto classDecl = dyn_cast<ClassDecl>(value))
0 commit comments