Skip to content

Commit 3b6a294

Browse files
committed
SILGen: Minimal backport of SILCloner changes on main
1 parent aabefa5 commit 3b6a294

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lib/SILGen/SILGenLocalArchetype.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class LocalArchetypeTransform : public SILCloner<LocalArchetypeTransform> {
3232

3333
GenericSignatureWithCapturedEnvironments sig;
3434
GenericEnvironment *env;
35+
SubstitutionMap subs;
3536

3637
public:
3738
LocalArchetypeTransform(SILFunction *F,
@@ -43,7 +44,7 @@ class LocalArchetypeTransform : public SILCloner<LocalArchetypeTransform> {
4344
// The primary archetypes of the old generic environment map to
4445
// primary archetypes of the new generic environment at the same
4546
// index and depth.
46-
Functor.SubsMap = env->getForwardingSubstitutionMap();
47+
subs = env->getForwardingSubstitutionMap();
4748

4849
// Local archetypes map to generic parameters at higher depths.
4950
MapLocalArchetypesOutOfContext mapOutOfContext(sig.baseGenericSig,
@@ -74,6 +75,22 @@ class LocalArchetypeTransform : public SILCloner<LocalArchetypeTransform> {
7475
}
7576
}
7677

78+
SILType remapType(SILType Ty) {
79+
return Ty.subst(Builder.getModule().Types, subs);
80+
}
81+
82+
CanType remapASTType(CanType ty) {
83+
return ty.subst(subs)->getCanonicalType();
84+
}
85+
86+
ProtocolConformanceRef remapConformance(Type Ty, ProtocolConformanceRef C) {
87+
return C.subst(Ty, subs);
88+
}
89+
90+
SubstitutionMap remapSubstitutionMap(SubstitutionMap subMap) {
91+
return subMap.subst(subs);
92+
}
93+
7794
void doIt() {
7895
auto &F = getBuilder().getFunction();
7996

@@ -146,4 +163,4 @@ void SILGenModule::recontextualizeCapturedLocalArchetypes(
146163

147164
LocalArchetypeTransform(F, sig).doIt();
148165
M.reclaimUnresolvedLocalArchetypeDefinitions();
149-
}
166+
}

0 commit comments

Comments
 (0)