@@ -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
}
@@ -2810,22 +2812,25 @@ namespace {
2810
2812
struct AccessEmitter {
2811
2813
SILGenFunction &SGF;
2812
2814
StorageType *Storage;
2815
+ SubstitutionMap Subs;
2813
2816
CanType FormalRValueType;
2814
2817
SGFAccessKind AccessKind;
2815
2818
2816
2819
Impl &asImpl () { return static_cast <Impl&>(*this ); }
2817
2820
2818
2821
AccessEmitter (SILGenFunction &SGF, StorageType *storage,
2819
- SGFAccessKind accessKind, CanType formalRValueType)
2820
- : SGF(SGF), Storage(storage), FormalRValueType(formalRValueType),
2821
- AccessKind (accessKind) {}
2822
+ SubstitutionMap subs, SGFAccessKind accessKind,
2823
+ CanType formalRValueType)
2824
+ : SGF(SGF), Storage(storage), Subs(subs),
2825
+ FormalRValueType (formalRValueType), AccessKind(accessKind) {}
2822
2826
2823
2827
void emitUsingStrategy (AccessStrategy strategy) {
2824
2828
switch (strategy.getKind ()) {
2825
2829
case AccessStrategy::Storage: {
2826
2830
auto typeData =
2827
2831
getPhysicalStorageTypeData (SGF.getTypeExpansionContext (), SGF.SGM ,
2828
- AccessKind, Storage, FormalRValueType);
2832
+ AccessKind, Storage, Subs,
2833
+ FormalRValueType);
2829
2834
return asImpl ().emitUsingStorage (typeData);
2830
2835
}
2831
2836
@@ -2871,15 +2876,17 @@ namespace {
2871
2876
case AccessorKind::MutableAddress: {
2872
2877
auto typeData =
2873
2878
getPhysicalStorageTypeData (SGF.getTypeExpansionContext (), SGF.SGM ,
2874
- AccessKind, Storage, FormalRValueType);
2879
+ AccessKind, Storage, Subs,
2880
+ FormalRValueType);
2875
2881
return asImpl ().emitUsingAddressor (accessor, isDirect, typeData);
2876
2882
}
2877
2883
2878
2884
case AccessorKind::Read:
2879
2885
case AccessorKind::Modify: {
2880
2886
auto typeData =
2881
2887
getPhysicalStorageTypeData (SGF.getTypeExpansionContext (), SGF.SGM ,
2882
- AccessKind, Storage, FormalRValueType);
2888
+ AccessKind, Storage, Subs,
2889
+ FormalRValueType);
2883
2890
return asImpl ().emitUsingCoroutineAccessor (accessor, isDirect,
2884
2891
typeData);
2885
2892
}
@@ -2953,7 +2960,6 @@ void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
2953
2960
AccessEmitter<NonMemberVarAccessEmitter, VarDecl> {
2954
2961
LValue &LV;
2955
2962
SILLocation Loc;
2956
- SubstitutionMap Subs;
2957
2963
LValueOptions Options;
2958
2964
Optional<ActorIsolation> ActorIso;
2959
2965
@@ -2964,8 +2970,8 @@ void LValue::addNonMemberVarComponent(SILGenFunction &SGF, SILLocation loc,
2964
2970
LValueOptions options,
2965
2971
Optional<ActorIsolation> actorIso,
2966
2972
LValue &lv)
2967
- : AccessEmitter(SGF, var, accessKind, formalRValueType),
2968
- LV (lv), Loc(loc), Subs(subs), Options(options), ActorIso(actorIso) {}
2973
+ : AccessEmitter(SGF, var, subs, accessKind, formalRValueType),
2974
+ LV (lv), Loc(loc), Options(options), ActorIso(actorIso) {}
2969
2975
2970
2976
void emitUsingAddressor (SILDeclRef addressor, bool isDirect,
2971
2977
LValueTypeData typeData) {
@@ -3512,14 +3518,14 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
3512
3518
using super = AccessEmitter<Impl, StorageType>;
3513
3519
using super::SGF;
3514
3520
using super::Storage;
3521
+ using super::Subs;
3515
3522
using super::FormalRValueType;
3516
3523
LValue &LV;
3517
3524
LValueOptions Options;
3518
3525
SILLocation Loc;
3519
3526
bool IsSuper;
3520
3527
bool IsOnSelfParameter; // Is self the self parameter in context.
3521
3528
CanType BaseFormalType;
3522
- SubstitutionMap Subs;
3523
3529
ArgumentList *ArgListForDiagnostics;
3524
3530
PreparedArguments Indices;
3525
3531
// If any, holds the actor we must switch to when performing the access.
@@ -3532,9 +3538,9 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
3532
3538
LValue &lv, ArgumentList *argListForDiagnostics,
3533
3539
PreparedArguments &&indices, bool isSelf = false ,
3534
3540
Optional<ActorIsolation> actorIso = None)
3535
- : super(SGF, storage, accessKind, formalRValueType), LV(lv),
3541
+ : super(SGF, storage, subs, accessKind, formalRValueType), LV(lv),
3536
3542
Options (options), Loc(loc), IsSuper(isSuper), IsOnSelfParameter(isSelf),
3537
- BaseFormalType(lv.getSubstFormalType()), Subs(subs),
3543
+ BaseFormalType(lv.getSubstFormalType()),
3538
3544
ArgListForDiagnostics(argListForDiagnostics),
3539
3545
Indices(std::move(indices)), ActorIso(actorIso) {}
3540
3546
0 commit comments