@@ -1385,63 +1385,18 @@ namespace {
1385
1385
return ClosureActorIsolation::forIndependent ();
1386
1386
1387
1387
// A non-escaping closure gets its isolation from its context.
1388
- Optional<ActorIsolation> parentIsolation;
1389
- auto parentDC = closure->getParent ();
1390
- switch (parentDC->getContextKind ()) {
1391
- case DeclContextKind::AbstractClosureExpr: {
1392
- auto parentClosureIsolation = cast<AbstractClosureExpr>(parentDC)
1393
- ->getActorIsolation ();
1394
- switch (parentClosureIsolation) {
1395
- case ClosureActorIsolation::Independent:
1396
- parentIsolation = ActorIsolation::forIndependent (
1397
- ActorIndependentKind::Safe);
1398
- break ;
1399
-
1400
- case ClosureActorIsolation::ActorInstance: {
1401
- auto selfDecl = parentClosureIsolation.getActorInstance ();
1402
- auto actorClass = selfDecl->getType ()->getRValueType ()
1403
- ->getClassOrBoundGenericClass ();
1404
- assert (actorClass && " Bad closure actor isolation?" );
1405
- parentIsolation = ActorIsolation::forActorInstance (actorClass);
1406
- break ;
1407
- }
1408
-
1409
- case ClosureActorIsolation::GlobalActor:
1410
- parentIsolation = ActorIsolation::forGlobalActor (
1411
- parentClosureIsolation.getGlobalActor ());
1412
- break ;
1413
- }
1414
- break ;
1415
- }
1416
-
1417
- case DeclContextKind::AbstractFunctionDecl:
1418
- case DeclContextKind::SubscriptDecl:
1419
- parentIsolation = getActorIsolation (
1420
- cast<ValueDecl>(parentDC->getAsDecl ()));
1421
- break ;
1422
-
1423
- case DeclContextKind::EnumElementDecl:
1424
- case DeclContextKind::ExtensionDecl:
1425
- case DeclContextKind::FileUnit:
1426
- case DeclContextKind::GenericTypeDecl:
1427
- case DeclContextKind::Initializer:
1428
- case DeclContextKind::Module:
1429
- case DeclContextKind::SerializedLocal:
1430
- case DeclContextKind::TopLevelCodeDecl:
1431
- return ClosureActorIsolation::forIndependent ();
1432
- }
1388
+ auto parentIsolation = getActorIsolationOfContext (closure->getParent ());
1433
1389
1434
1390
// We must have parent isolation determined to get here.
1435
- assert (parentIsolation && " Missing parent isolation?" );
1436
- switch (*parentIsolation) {
1391
+ switch (parentIsolation) {
1437
1392
case ActorIsolation::Independent:
1438
1393
case ActorIsolation::IndependentUnsafe:
1439
1394
case ActorIsolation::Unspecified:
1440
1395
return ClosureActorIsolation::forIndependent ();
1441
1396
1442
1397
case ActorIsolation::GlobalActor: {
1443
1398
Type globalActorType = closure->mapTypeIntoContext (
1444
- parentIsolation-> getGlobalActor ()->mapTypeOutOfContext ());
1399
+ parentIsolation. getGlobalActor ()->mapTypeOutOfContext ());
1445
1400
return ClosureActorIsolation::forGlobalActor (globalActorType);
1446
1401
}
1447
1402
0 commit comments