Skip to content

Commit a71710b

Browse files
committed
SIL: Clean up TypeSubstCloner::remapParentFunction()
I think the assertion failure referenced from the FIXME comment has been fixed.
1 parent a1ea56b commit a71710b

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

include/swift/SIL/TypeSubstCloner.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,12 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
297297
if (SubsMap.empty())
298298
return false;
299299

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;
309306
}
310307

311308
enum { ForInlining = true };
@@ -314,7 +311,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
314311
/// \param SubsMap - the substitutions of the inlining/specialization process.
315312
/// \param RemappedSig - the generic signature.
316313
static SILFunction *remapParentFunction(FunctionBuilderTy &FuncBuilder,
317-
SILModule &M,
314+
SILModule &M,
318315
SILFunction *ParentFunction,
319316
SubstitutionMap SubsMap,
320317
GenericSignature *RemappedSig,
@@ -325,14 +322,15 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
325322
if (!RemappedSig || !OriginalEnvironment)
326323
return ParentFunction;
327324

328-
if (!substitutionsChangeGenericTypeParameters(SubsMap, RemappedSig))
329-
return ParentFunction;
330-
331325
if (SubsMap.hasArchetypes())
332326
SubsMap = SubsMap.mapReplacementTypesOutOfContext();
333327

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.
336334
if (SubsMap.hasArchetypes())
337335
return ParentFunction;
338336

0 commit comments

Comments
 (0)