@@ -448,9 +448,9 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
448448
449449 SILLocation remapLocation (SILLocation Loc) { return Loc; }
450450 const SILDebugScope *remapScope (const SILDebugScope *DS) { return DS; }
451+
451452 SILType remapType (SILType Ty) {
452- // Substitute local archetypes, if we have any.
453- if (Ty.hasLocalArchetype ()) {
453+ if (Functor.SubsMap || Ty.hasLocalArchetype ()) {
454454 Ty = Ty.subst (Builder.getModule (), Functor, Functor,
455455 CanGenericSignature ());
456456 }
@@ -459,16 +459,14 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
459459 }
460460
461461 CanType remapASTType (CanType ty) {
462- // Substitute local archetypes, if we have any.
463- if (ty->hasLocalArchetype ())
462+ if (Functor.SubsMap || ty->hasLocalArchetype ())
464463 ty = ty.subst (Functor, Functor)->getCanonicalType ();
465464
466465 return ty;
467466 }
468467
469468 ProtocolConformanceRef remapConformance (Type Ty, ProtocolConformanceRef C) {
470- // If we have local archetypes to substitute, do so now.
471- if (Ty->hasLocalArchetype ())
469+ if (Functor.SubsMap || Ty->hasLocalArchetype ())
472470 C = C.subst (Ty, Functor, Functor);
473471
474472 return C;
@@ -485,7 +483,7 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
485483
486484 SubstitutionMap remapSubstitutionMap (SubstitutionMap Subs) {
487485 // If we have local archetypes to substitute, do so now.
488- if (Subs.hasLocalArchetypes ())
486+ if (Subs.hasLocalArchetypes () || Functor. SubsMap )
489487 Subs = Subs.subst (Functor, Functor);
490488
491489 return Subs;
0 commit comments