@@ -1565,6 +1565,7 @@ class DestructureInputs {
15651565 TypeConverter &TC;
15661566 const Conventions &Convs;
15671567 const ForeignInfo &Foreign;
1568+ std::optional<ActorIsolation> IsolationInfo;
15681569 struct ForeignSelfInfo {
15691570 AbstractionPattern OrigSelfParam;
15701571 AnyFunctionType::CanParam SubstSelfParam;
@@ -1577,9 +1578,10 @@ class DestructureInputs {
15771578public:
15781579 DestructureInputs (TypeExpansionContext expansion, TypeConverter &TC,
15791580 const Conventions &conventions, const ForeignInfo &foreign,
1581+ std::optional<ActorIsolation> isolationInfo,
15801582 SmallVectorImpl<SILParameterInfo> &inputs)
15811583 : expansion(expansion), TC(TC), Convs(conventions), Foreign(foreign),
1582- Inputs(inputs) {}
1584+ IsolationInfo(isolationInfo), Inputs(inputs) {}
15831585
15841586 void destructure (AbstractionPattern origType,
15851587 CanAnyFunctionType::CanParamArrayRef params,
@@ -1641,6 +1643,23 @@ class DestructureInputs {
16411643 };
16421644 }
16431645
1646+ // If we are an async function that is unspecified or nonisolated, insert an
1647+ // isolated parameter if NonIsolatedAsyncInheritsIsolationFromContext is
1648+ // enabled.
1649+ if (TC.Context .LangOpts .hasFeature (
1650+ Feature::NonIsolatedAsyncInheritsIsolationFromContext) &&
1651+ IsolationInfo &&
1652+ IsolationInfo->getKind () == ActorIsolation::CallerIsolationInheriting &&
1653+ extInfoBuilder.isAsync ()) {
1654+ auto actorProtocol = TC.Context .getProtocol (KnownProtocolKind::Actor);
1655+ auto actorType =
1656+ ExistentialType::get (actorProtocol->getDeclaredInterfaceType ());
1657+ addParameter (CanType (actorType).wrapInOptionalType (),
1658+ ParameterConvention::Direct_Guaranteed,
1659+ ParameterTypeFlags ().withIsolated (true ),
1660+ true /* implicit leading parameter*/ );
1661+ }
1662+
16441663 // Add any foreign parameters that are positioned at the start
16451664 // of the sequence. visit() will add foreign parameters that are
16461665 // positioned after any parameters it adds.
@@ -2472,8 +2491,17 @@ static CanSILFunctionType getSILFunctionType(
24722491 // Destructure the input tuple type.
24732492 SmallVector<SILParameterInfo, 8 > inputs;
24742493 {
2494+ std::optional<ActorIsolation> actorIsolation;
2495+ if (constant) {
2496+ if (constant->kind == SILDeclRef::Kind::Deallocator) {
2497+ actorIsolation = ActorIsolation::forNonisolated (false );
2498+ } else {
2499+ actorIsolation =
2500+ getActorIsolationOfContext (constant->getInnermostDeclContext ());
2501+ }
2502+ }
24752503 DestructureInputs destructurer (expansionContext, TC, conventions,
2476- foreignInfo, inputs);
2504+ foreignInfo, actorIsolation, inputs);
24772505 destructurer.destructure (origType, substFnInterfaceType.getParams (),
24782506 extInfoBuilder, unimplementable);
24792507 }
@@ -2561,8 +2589,9 @@ static CanSILFunctionType getSILFunctionTypeForInitAccessor(
25612589 {
25622590 bool unimplementable = false ;
25632591 ForeignInfo foreignInfo;
2592+ std::optional<ActorIsolation> actorIsolation; // For now always null.
25642593 DestructureInputs destructurer (context, TC, conventions, foreignInfo,
2565- inputs);
2594+ actorIsolation, inputs);
25662595 destructurer.destructure (
25672596 origType, substAccessorType.getParams (),
25682597 extInfoBuilder.withRepresentation (SILFunctionTypeRepresentation::Thin),
0 commit comments