@@ -233,10 +233,12 @@ static LValueTypeData getPhysicalStorageTypeData(TypeExpansionContext context,
233
233
SILGenModule &SGM,
234
234
SGFAccessKind accessKind,
235
235
AbstractStorageDecl *storage,
236
+ SubstitutionMap subs,
236
237
CanType substFormalType) {
237
238
assert (!isa<ReferenceStorageType>(substFormalType));
238
239
auto origFormalType = SGM.Types .getAbstractionPattern (storage)
239
- .getReferenceStorageReferentType ();
240
+ .getReferenceStorageReferentType ()
241
+ .withSubstitutions (subs);
240
242
return getAbstractedTypeData (context, SGM, accessKind, origFormalType,
241
243
substFormalType);
242
244
}
@@ -2801,22 +2803,25 @@ namespace {
2801
2803
struct AccessEmitter {
2802
2804
SILGenFunction &SGF;
2803
2805
StorageType *Storage;
2806
+ SubstitutionMap Subs;
2804
2807
CanType FormalRValueType;
2805
2808
SGFAccessKind AccessKind;
2806
2809
2807
2810
Impl &asImpl () { return static_cast <Impl&>(*this ); }
2808
2811
2809
2812
AccessEmitter (SILGenFunction &SGF, StorageType *storage,
2810
- SGFAccessKind accessKind, CanType formalRValueType)
2811
- : SGF(SGF), Storage(storage), FormalRValueType(formalRValueType),
2812
- AccessKind (accessKind) {}
2813
+ SubstitutionMap subs, SGFAccessKind accessKind,
2814
+ CanType formalRValueType)
2815
+ : SGF(SGF), Storage(storage), Subs(subs),
2816
+ FormalRValueType (formalRValueType), AccessKind(accessKind) {}
2813
2817
2814
2818
void emitUsingStrategy (AccessStrategy strategy) {
2815
2819
switch (strategy.getKind ()) {
2816
2820
case AccessStrategy::Storage: {
2817
2821
auto typeData =
2818
2822
getPhysicalStorageTypeData (SGF.getTypeExpansionContext (), SGF.SGM ,
2819
- AccessKind, Storage, FormalRValueType);
2823
+ AccessKind, Storage, Subs,
2824
+ FormalRValueType);
2820
2825
return asImpl ().emitUsingStorage (typeData);
2821
2826
}
2822
2827
@@ -2862,15 +2867,17 @@ namespace {
2862
2867
case AccessorKind::MutableAddress: {
2863
2868
auto typeData =
2864
2869
getPhysicalStorageTypeData (SGF.getTypeExpansionContext (), SGF.SGM ,
2865
- AccessKind, Storage, FormalRValueType);
2870
+ AccessKind, Storage, Subs,
2871
+ FormalRValueType);
2866
2872
return asImpl ().emitUsingAddressor (accessor, isDirect, typeData);
2867
2873
}
2868
2874
2869
2875
case AccessorKind::Read:
2870
2876
case AccessorKind::Modify: {
2871
2877
auto typeData =
2872
2878
getPhysicalStorageTypeData (SGF.getTypeExpansionContext (), SGF.SGM ,
2873
- AccessKind, Storage, FormalRValueType);
2879
+ AccessKind, Storage, Subs,
2880
+ FormalRValueType);
2874
2881
return asImpl ().emitUsingCoroutineAccessor (accessor, isDirect,
2875
2882
typeData);
2876
2883
}
@@ -2944,7 +2951,6 @@ void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
2944
2951
AccessEmitter<NonMemberVarAccessEmitter, VarDecl> {
2945
2952
LValue &LV;
2946
2953
SILLocation Loc;
2947
- SubstitutionMap Subs;
2948
2954
LValueOptions Options;
2949
2955
Optional<ActorIsolation> ActorIso;
2950
2956
@@ -2955,8 +2961,8 @@ void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
2955
2961
LValueOptions options,
2956
2962
Optional<ActorIsolation> actorIso,
2957
2963
LValue &lv)
2958
- : AccessEmitter(SGF, var, accessKind, formalRValueType),
2959
- LV (lv), Loc(loc), Subs(subs), Options(options), ActorIso(actorIso) {}
2964
+ : AccessEmitter(SGF, var, subs, accessKind, formalRValueType),
2965
+ LV (lv), Loc(loc), Options(options), ActorIso(actorIso) {}
2960
2966
2961
2967
void emitUsingAddressor (SILDeclRef addressor, bool isDirect,
2962
2968
LValueTypeData typeData) {
@@ -3538,14 +3544,14 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
3538
3544
using super = AccessEmitter<Impl, StorageType>;
3539
3545
using super::SGF;
3540
3546
using super::Storage;
3547
+ using super::Subs;
3541
3548
using super::FormalRValueType;
3542
3549
LValue &LV;
3543
3550
LValueOptions Options;
3544
3551
SILLocation Loc;
3545
3552
bool IsSuper;
3546
3553
bool IsOnSelfParameter; // Is self the self parameter in context.
3547
3554
CanType BaseFormalType;
3548
- SubstitutionMap Subs;
3549
3555
ArgumentList *ArgListForDiagnostics;
3550
3556
PreparedArguments Indices;
3551
3557
// If any, holds the actor we must switch to when performing the access.
@@ -3558,9 +3564,9 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
3558
3564
LValue &lv, ArgumentList *argListForDiagnostics,
3559
3565
PreparedArguments &&indices, bool isSelf = false ,
3560
3566
Optional<ActorIsolation> actorIso = None)
3561
- : super(SGF, storage, accessKind, formalRValueType), LV(lv),
3567
+ : super(SGF, storage, subs, accessKind, formalRValueType), LV(lv),
3562
3568
Options (options), Loc(loc), IsSuper(isSuper), IsOnSelfParameter(isSelf),
3563
- BaseFormalType(lv.getSubstFormalType()), Subs(subs),
3569
+ BaseFormalType(lv.getSubstFormalType()),
3564
3570
ArgListForDiagnostics(argListForDiagnostics),
3565
3571
Indices(std::move(indices)), ActorIso(actorIso) {}
3566
3572
0 commit comments