@@ -175,70 +175,15 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
175175 }
176176
177177protected:
178+ bool shouldSubstOpaqueArchetypes () const { return true ; }
179+
178180 SILType remapType (SILType Ty) {
179181 SILType &Sty = TypeCache[Ty];
180- if (!Sty) {
181- Sty = Ty;
182-
183- Sty = Sty.subst (getBuilder ().getModule (), Functor, Functor);
184-
185- auto context = getBuilder ().getTypeExpansionContext ();
186-
187- if (!Sty.hasOpaqueArchetype () ||
188- !context.shouldLookThroughOpaqueTypeArchetypes ())
189- return Sty;
190-
191- // Remap types containing opaque result types in the current context.
192- Sty = getBuilder ().getTypeLowering (Sty).getLoweredType ().getCategoryType (
193- Sty.getCategory ());
194- }
182+ if (!Sty)
183+ Sty = SILClonerWithScopes<ImplClass>::remapType (Ty);
195184 return Sty;
196185 }
197186
198- CanType remapASTType (CanType ty) {
199- auto substTy = ty.subst (Functor, Functor)->getCanonicalType ();
200-
201- auto context = getBuilder ().getTypeExpansionContext ();
202-
203- if (!substTy->hasOpaqueArchetype () ||
204- !context.shouldLookThroughOpaqueTypeArchetypes ())
205- return substTy;
206-
207- // Remap types containing opaque result types in the current context.
208- return substOpaqueTypesWithUnderlyingTypes (substTy, context,
209- /* allowLoweredTypes=*/ false );
210- }
211-
212- ProtocolConformanceRef remapConformance (Type ty,
213- ProtocolConformanceRef conf) {
214- auto substTy = ty.subst (Functor, Functor)->getCanonicalType ();
215- auto substConf = conf.subst (ty, Functor, Functor);
216-
217- auto context = getBuilder ().getTypeExpansionContext ();
218-
219- if (!substTy->hasOpaqueArchetype () ||
220- !context.shouldLookThroughOpaqueTypeArchetypes ())
221- return substConf;
222-
223- return substOpaqueTypesWithUnderlyingTypes (substConf, substTy, context);
224- }
225-
226- SubstitutionMap remapSubstitutionMap (SubstitutionMap Subs) {
227- Subs = Subs.subst (Functor, Functor);
228-
229- auto context = getBuilder ().getTypeExpansionContext ();
230-
231- if (!Subs.hasOpaqueArchetypes () ||
232- !context.shouldLookThroughOpaqueTypeArchetypes ())
233- return Subs;
234-
235- ReplaceOpaqueTypesWithUnderlyingTypes replacer (
236- context.getContext (), context.getResilienceExpansion (),
237- context.isWholeModuleContext ());
238- return Subs.subst (replacer, replacer,
239- SubstFlags::SubstituteOpaqueArchetypes);
240- }
241-
242187 void visitApplyInst (ApplyInst *Inst) {
243188 ApplySiteCloningHelper Helper (ApplySite (Inst), *this );
244189 ApplyInst *N =
0 commit comments