@@ -966,7 +966,8 @@ static void emitMemberInit(SILGenFunction &SGF, VarDecl *selfDecl,
966966 }
967967}
968968
969- static Type getInitializationTypeInContext (
969+ static std::pair<AbstractionPattern, CanType>
970+ getInitializationTypeInContext (
970971 DeclContext *fromDC, DeclContext *toDC,
971972 Pattern *pattern) {
972973 auto interfaceType = pattern->getType ()->mapTypeOutOfContext ();
@@ -981,9 +982,13 @@ static Type getInitializationTypeInContext(
981982 }
982983 }
983984
984- auto resultType = toDC->mapTypeIntoContext (interfaceType);
985+ AbstractionPattern origType (
986+ fromDC->getGenericSignatureOfContext ().getCanonicalSignature (),
987+ interfaceType->getCanonicalType ());
985988
986- return resultType;
989+ auto substType = toDC->mapTypeIntoContext (interfaceType)->getCanonicalType ();
990+
991+ return std::make_pair (origType, substType);
987992}
988993
989994void SILGenFunction::emitMemberInitializers (DeclContext *dc,
@@ -1006,15 +1011,16 @@ void SILGenFunction::emitMemberInitializers(DeclContext *dc,
10061011
10071012 // Get the type of the initialization result, in terms
10081013 // of the constructor context's archetypes.
1009- CanType resultType = getInitializationTypeInContext (
1010- pbd->getDeclContext (), dc, varPattern)->getCanonicalType ();
1011- AbstractionPattern origResultType (resultType);
1014+ auto resultType = getInitializationTypeInContext (
1015+ pbd->getDeclContext (), dc, varPattern);
1016+ AbstractionPattern origType = resultType.first ;
1017+ CanType substType = resultType.second ;
10121018
10131019 // FIXME: Can emitMemberInit() share code with
10141020 // InitializationForPattern in SILGenDecl.cpp?
10151021 RValue result = emitApplyOfStoredPropertyInitializer (
10161022 init, pbd->getAnchoringVarDecl (i), subs,
1017- resultType, origResultType ,
1023+ substType, origType ,
10181024 SGFContext ());
10191025
10201026 // If we have the backing storage for a property with an attached
0 commit comments