Skip to content

Commit 4de6dca

Browse files
committed
SIL: Fix latent bug in TypeSubstCloner::remapSubstitutionMap()
We didn't erase opaque archetypes like we did when remapping types and conformances.
1 parent 77f9486 commit 4de6dca

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

include/swift/SIL/TypeSubstCloner.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,18 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
205205
}
206206

207207
SubstitutionMap remapSubstitutionMap(SubstitutionMap Subs) {
208-
return Subs.subst(SubsMap);
208+
auto context = getBuilder().getTypeExpansionContext();
209+
210+
Subs = Subs.subst(SubsMap);
211+
if (!Subs.hasOpaqueArchetypes() ||
212+
!context.shouldLookThroughOpaqueTypeArchetypes())
213+
return Subs;
214+
215+
ReplaceOpaqueTypesWithUnderlyingTypes replacer(
216+
context.getContext(), context.getResilienceExpansion(),
217+
context.isWholeModuleContext());
218+
return Subs.subst(replacer, replacer,
219+
SubstFlags::SubstituteOpaqueArchetypes);
209220
}
210221

211222
void visitApplyInst(ApplyInst *Inst) {

0 commit comments

Comments
 (0)