@@ -297,15 +297,12 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
297
297
if (SubsMap.empty ())
298
298
return false ;
299
299
300
- auto Params = Sig->getSubstitutableParams ();
301
- return std::any_of (Params.begin (), Params.end (), [&](Type ParamType) {
302
- // FIXME: It would be more elegant to run
303
- // SubsMap.mapReplacementTypesOutOfContext() bup front, but it can assert.
304
- Type Substitution = Type (ParamType).subst (SubsMap)->mapTypeOutOfContext ();
305
- return !Substitution->isOpenedExistential () &&
306
- (Substitution->getCanonicalType () !=
307
- ParamType->getCanonicalType ());
308
- });
300
+ for (auto ParamType : Sig->getSubstitutableParams ()) {
301
+ if (!Type (ParamType).subst (SubsMap)->isEqual (ParamType))
302
+ return true ;
303
+ }
304
+
305
+ return false ;
309
306
}
310
307
311
308
enum { ForInlining = true };
@@ -314,7 +311,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
314
311
// / \param SubsMap - the substitutions of the inlining/specialization process.
315
312
// / \param RemappedSig - the generic signature.
316
313
static SILFunction *remapParentFunction (FunctionBuilderTy &FuncBuilder,
317
- SILModule &M,
314
+ SILModule &M,
318
315
SILFunction *ParentFunction,
319
316
SubstitutionMap SubsMap,
320
317
GenericSignature *RemappedSig,
@@ -325,14 +322,15 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
325
322
if (!RemappedSig || !OriginalEnvironment)
326
323
return ParentFunction;
327
324
328
- if (!substitutionsChangeGenericTypeParameters (SubsMap, RemappedSig))
329
- return ParentFunction;
330
-
331
325
if (SubsMap.hasArchetypes ())
332
326
SubsMap = SubsMap.mapReplacementTypesOutOfContext ();
333
327
334
- // This is a bug in mapReplacementTypesOutOfContext(). Archetypes can't be
335
- // mangled, only type parameters can; ignore this for now.
328
+ if (!substitutionsChangeGenericTypeParameters (SubsMap, RemappedSig))
329
+ return ParentFunction;
330
+
331
+ // Note that mapReplacementTypesOutOfContext() can't do anything for
332
+ // opened existentials, and since archetypes can't be mangled, ignore
333
+ // this case for now.
336
334
if (SubsMap.hasArchetypes ())
337
335
return ParentFunction;
338
336
0 commit comments