@@ -192,15 +192,12 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
192192 // If we have local archetypes to substitute, check whether that's
193193 // relevant to this particular substitution.
194194 if (!LocalArchetypeSubs.empty ()) {
195- for ( auto ty : Subs.getReplacementTypes ()) {
195+ if ( Subs.hasLocalArchetypes ()) {
196196 // If we found a type containing a local archetype, substitute
197197 // open existentials throughout the substitution map.
198- if (ty->hasLocalArchetype ()) {
199- Subs = Subs.subst (QueryTypeSubstitutionMapOrIdentity{
200- LocalArchetypeSubs},
201- MakeAbstractConformanceForGenericType ());
202- break ;
203- }
198+ Subs = Subs.subst (QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
199+ MakeAbstractConformanceForGenericType (),
200+ SubstFlags::PreservePackExpansionLevel);
204201 }
205202 }
206203
@@ -223,7 +220,9 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
223220 return Ty.subst (
224221 Builder.getModule (),
225222 QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
226- MakeAbstractConformanceForGenericType ());
223+ MakeAbstractConformanceForGenericType (),
224+ CanGenericSignature (),
225+ SubstFlags::PreservePackExpansionLevel);
227226 }
228227 SILType getOpType (SILType Ty) {
229228 Ty = getTypeInClonedContext (Ty);
@@ -242,7 +241,8 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
242241
243242 return ty.subst (
244243 QueryTypeSubstitutionMapOrIdentity{LocalArchetypeSubs},
245- MakeAbstractConformanceForGenericType ()
244+ MakeAbstractConformanceForGenericType (),
245+ SubstFlags::PreservePackExpansionLevel
246246 )->getCanonicalType ();
247247 }
248248
@@ -355,7 +355,8 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
355355 conformance.subst (ty,
356356 QueryTypeSubstitutionMapOrIdentity{
357357 LocalArchetypeSubs},
358- MakeAbstractConformanceForGenericType ());
358+ MakeAbstractConformanceForGenericType (),
359+ SubstFlags::PreservePackExpansionLevel);
359360 }
360361
361362 return asImpl ().remapConformance (getASTTypeInClonedContext (ty),
0 commit comments