Skip to content

Commit b0cc3ff

Browse files
committed
[SubstitutionMap] Canonicalize non-substitutable replacement types.
When we compute a replacement type for a non-substitutable generic parameter, canonicalize the type when our generic signature is canonical. This ensures that the canonical substitution map will have canonical types for all of the replacement types… including those for non-substitutable generic parameters that aren’t part of the FoldingSet profile.
1 parent 5ed639f commit b0cc3ff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/AST/SubstitutionMap.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ Type SubstitutionMap::lookupSubstitution(CanSubstitutableType type) const {
275275

276276
// Substitute into the replacement type.
277277
replacementType = concreteType.subst(*this);
278+
279+
// If the generic signature is canonical, canonicalize the replacement type.
280+
if (getGenericSignature()->isCanonical())
281+
replacementType = replacementType->getCanonicalType();
282+
278283
return replacementType;
279284
}
280285

@@ -290,6 +295,11 @@ Type SubstitutionMap::lookupSubstitution(CanSubstitutableType type) const {
290295
replacementType = ErrorType::get(type);
291296

292297
replacementType = lookupSubstitution(cast<SubstitutableType>(canonicalType));
298+
299+
// If the generic signature is canonical, canonicalize the replacement type.
300+
if (getGenericSignature()->isCanonical())
301+
replacementType = replacementType->getCanonicalType();
302+
293303
return replacementType;
294304
}
295305

0 commit comments

Comments
 (0)