AST: Canonicalize opaque archetype substitution maps in the solver arena

Preserving sugar if we have type variables uses way too much memory.

Canonicalize these substitution maps for now, as a (temporary?) workaround.

In the future, if we decide preserving sugar is more important than a
few dozen Mb of memory usage, we can also bump the arena memory limit,
instead.

Fixes rdar://166237860.
Fixes rdar://165863647.
This commit is contained in:
Slava Pestov
2025-12-12 18:09:07 -05:00
parent f82cf1ebfb
commit 54521bd21b

View File

@@ -6086,6 +6086,11 @@ GenericEnvironment *GenericEnvironment::forPrimary(GenericSignature signature) {
/// outer substitutions.
GenericEnvironment *GenericEnvironment::forOpaqueType(
OpaqueTypeDecl *opaque, SubstitutionMap subs) {
// Don't preserve sugar if we have type variables, because this leads to
// excessive solver arena memory usage.
if (subs.getRecursiveProperties().hasTypeVariable())
subs = subs.getCanonical();
auto &ctx = opaque->getASTContext();
auto properties = ArchetypeType::archetypeProperties(