Skip to content

Commit a2ca44b

Browse files
committed
SILGen: Pass the correct abstraction pattern to emitApplyOfStoredPropertyInitializer()
1 parent adbcd6a commit a2ca44b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/SILGen/SILGenConstructor.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

989994
void 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

Comments
 (0)