@@ -966,7 +966,8 @@ static void emitMemberInit(SILGenFunction &SGF, VarDecl *selfDecl,
966
966
}
967
967
}
968
968
969
- static Type getInitializationTypeInContext (
969
+ static std::pair<AbstractionPattern, CanType>
970
+ getInitializationTypeInContext (
970
971
DeclContext *fromDC, DeclContext *toDC,
971
972
Pattern *pattern) {
972
973
auto interfaceType = pattern->getType ()->mapTypeOutOfContext ();
@@ -981,9 +982,13 @@ static Type getInitializationTypeInContext(
981
982
}
982
983
}
983
984
984
- auto resultType = toDC->mapTypeIntoContext (interfaceType);
985
+ AbstractionPattern origType (
986
+ fromDC->getGenericSignatureOfContext ().getCanonicalSignature (),
987
+ interfaceType->getCanonicalType ());
985
988
986
- return resultType;
989
+ auto substType = toDC->mapTypeIntoContext (interfaceType)->getCanonicalType ();
990
+
991
+ return std::make_pair (origType, substType);
987
992
}
988
993
989
994
void SILGenFunction::emitMemberInitializers (DeclContext *dc,
@@ -1006,15 +1011,16 @@ void SILGenFunction::emitMemberInitializers(DeclContext *dc,
1006
1011
1007
1012
// Get the type of the initialization result, in terms
1008
1013
// 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 ;
1012
1018
1013
1019
// FIXME: Can emitMemberInit() share code with
1014
1020
// InitializationForPattern in SILGenDecl.cpp?
1015
1021
RValue result = emitApplyOfStoredPropertyInitializer (
1016
1022
init, pbd->getAnchoringVarDecl (i), subs,
1017
- resultType, origResultType ,
1023
+ substType, origType ,
1018
1024
SGFContext ());
1019
1025
1020
1026
// If we have the backing storage for a property with an attached
0 commit comments