@@ -1565,6 +1565,7 @@ class DestructureInputs {
1565
1565
TypeConverter &TC;
1566
1566
const Conventions &Convs;
1567
1567
const ForeignInfo &Foreign;
1568
+ std::optional<ActorIsolation> IsolationInfo;
1568
1569
struct ForeignSelfInfo {
1569
1570
AbstractionPattern OrigSelfParam;
1570
1571
AnyFunctionType::CanParam SubstSelfParam;
@@ -1577,9 +1578,10 @@ class DestructureInputs {
1577
1578
public:
1578
1579
DestructureInputs (TypeExpansionContext expansion, TypeConverter &TC,
1579
1580
const Conventions &conventions, const ForeignInfo &foreign,
1581
+ std::optional<ActorIsolation> isolationInfo,
1580
1582
SmallVectorImpl<SILParameterInfo> &inputs)
1581
1583
: expansion(expansion), TC(TC), Convs(conventions), Foreign(foreign),
1582
- Inputs(inputs) {}
1584
+ IsolationInfo(isolationInfo), Inputs(inputs) {}
1583
1585
1584
1586
void destructure (AbstractionPattern origType,
1585
1587
CanAnyFunctionType::CanParamArrayRef params,
@@ -1641,6 +1643,23 @@ class DestructureInputs {
1641
1643
};
1642
1644
}
1643
1645
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
+
1644
1663
// Add any foreign parameters that are positioned at the start
1645
1664
// of the sequence. visit() will add foreign parameters that are
1646
1665
// positioned after any parameters it adds.
@@ -2472,8 +2491,17 @@ static CanSILFunctionType getSILFunctionType(
2472
2491
// Destructure the input tuple type.
2473
2492
SmallVector<SILParameterInfo, 8 > inputs;
2474
2493
{
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
+ }
2475
2503
DestructureInputs destructurer (expansionContext, TC, conventions,
2476
- foreignInfo, inputs);
2504
+ foreignInfo, actorIsolation, inputs);
2477
2505
destructurer.destructure (origType, substFnInterfaceType.getParams (),
2478
2506
extInfoBuilder, unimplementable);
2479
2507
}
@@ -2561,8 +2589,9 @@ static CanSILFunctionType getSILFunctionTypeForInitAccessor(
2561
2589
{
2562
2590
bool unimplementable = false ;
2563
2591
ForeignInfo foreignInfo;
2592
+ std::optional<ActorIsolation> actorIsolation; // For now always null.
2564
2593
DestructureInputs destructurer (context, TC, conventions, foreignInfo,
2565
- inputs);
2594
+ actorIsolation, inputs);
2566
2595
destructurer.destructure (
2567
2596
origType, substAccessorType.getParams (),
2568
2597
extInfoBuilder.withRepresentation (SILFunctionTypeRepresentation::Thin),
0 commit comments