@@ -2683,6 +2683,9 @@ namespace {
26832683 strategy.getWriteStrategy (),
26842684 typeData);
26852685 }
2686+
2687+ case AccessStrategy::DispatchToDistributedThunk:
2688+ return asImpl ().emitUsingDistributedThunk ();
26862689 }
26872690 llvm_unreachable (" unknown kind" );
26882691 }
@@ -2888,6 +2891,11 @@ void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
28882891 if (address.getType ().is <ReferenceStorageType>())
28892892 LV.add <OwnershipComponent>(typeData);
28902893 }
2894+
2895+ void emitUsingDistributedThunk () {
2896+ llvm_unreachable (" cannot dispatch non-member var via distributed thunk" );
2897+ }
2898+
28912899 } emitter(SGF, loc, var, subs, accessKind, formalRValueType, options,
28922900 actorIso, *this );
28932901
@@ -3183,11 +3191,11 @@ static SGFAccessKind getBaseAccessKind(SILGenModule &SGM,
31833191 }
31843192
31853193 case AccessStrategy::DirectToAccessor:
3186- case AccessStrategy::DispatchToAccessor: {
3194+ case AccessStrategy::DispatchToAccessor:
3195+ case AccessStrategy::DispatchToDistributedThunk: {
31873196 auto accessor = member->getOpaqueAccessor (strategy.getAccessor ());
31883197 return getBaseAccessKindForAccessor (SGM, accessor, baseFormalType);
31893198 }
3190-
31913199 }
31923200 llvm_unreachable (" bad access strategy" );
31933201}
@@ -3395,6 +3403,19 @@ void LValue::addMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
33953403 LV.add <OwnershipComponent>(typeData);
33963404 }
33973405 }
3406+
3407+ void emitUsingDistributedThunk () {
3408+ auto *var = cast<VarDecl>(Storage);
3409+ SILDeclRef accessor (var->getDistributedThunk (), SILDeclRef::Kind::Func,
3410+ /* isForeign=*/ false , /* isDistributed=*/ true );
3411+
3412+ auto typeData = getLogicalStorageTypeData (
3413+ SGF.getTypeExpansionContext (), SGF.SGM , AccessKind, FormalRValueType);
3414+
3415+ asImpl ().emitUsingGetterSetter (accessor, /* isDirect=*/ false ,
3416+ /* isDistributed=*/ true , typeData);
3417+ }
3418+
33983419 } emitter (SGF, loc, var, subs, isSuper, accessKind,
33993420 formalRValueType, options, *this ,
34003421 /* indices for diags*/ nullptr , /* indices*/ PreparedArguments (),
@@ -3570,6 +3591,10 @@ void LValue::addMemberSubscriptComponent(SILGenFunction &SGF, SILLocation loc,
35703591 void emitUsingStorage (LValueTypeData typeData) {
35713592 llvm_unreachable (" subscripts never have storage" );
35723593 }
3594+
3595+ void emitUsingDistributedThunk () {
3596+ llvm_unreachable (" subscripts cannot be dispatch via distributed thunk" );
3597+ }
35733598 } emitter (SGF, loc, decl, subs, isSuper, accessKind, formalRValueType,
35743599 options, *this , argListForDiagnostics, std::move (indices),
35753600 isOnSelfParameter, actorIso);
0 commit comments