Skip to content

Commit 530a10a

Browse files
committed
SIL: Correct handling of local archetypes in remapConformance()
1 parent 1399202 commit 530a10a

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

include/swift/SIL/TypeSubstCloner.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,12 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
226226

227227
ProtocolConformanceRef remapConformance(Type ty,
228228
ProtocolConformanceRef conf) {
229-
// If we have local archetypes to substitute, do so now.
230-
if (ty->hasLocalArchetype() && !LocalArchetypeSubs.empty()) {
231-
conf =
232-
conf.subst(ty,
233-
QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
234-
MakeAbstractConformanceForGenericType());
235-
ty = ty.subst(
236-
QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
237-
MakeAbstractConformanceForGenericType());
238-
}
229+
SubstitutionMapWithLocalArchetypes functor(SubsMap, LocalArchetypeSubs);
230+
auto substTy = ty.subst(functor, functor)->getCanonicalType();
231+
auto substConf = conf.subst(ty, functor, functor);
239232

240233
auto context = getBuilder().getTypeExpansionContext();
241234

242-
auto substTy = ty.subst(SubsMap)->getCanonicalType();
243-
auto substConf = conf.subst(ty, SubsMap);
244235
if (!substTy->hasOpaqueArchetype() ||
245236
!context.shouldLookThroughOpaqueTypeArchetypes())
246237
return substConf;

0 commit comments

Comments
 (0)