Sema: Tighten up invariants for createDesignatedInitOverride()

This commit is contained in:
Slava Pestov
2022-07-29 11:46:31 -04:00
parent 5ad096f7ee
commit fcf79485d6
3 changed files with 7 additions and 2 deletions

View File

@@ -539,6 +539,7 @@ SubstitutionMap::getOverrideSubstitutions(const ClassDecl *baseClass,
auto derivedClassTy = derivedClass->getDeclaredInterfaceType();
baseSubMap = derivedClassTy->getContextSubstitutionMap(
baseClass->getParentModule(), baseClass);
assert(!baseSubMap.hasArchetypes());
}
unsigned origDepth = 0;

View File

@@ -4835,8 +4835,10 @@ TypeBase::getContextSubstitutions(const DeclContext *dc,
// Find the superclass type with the context matching that of the member.
auto *ownerNominal = dc->getSelfNominalTypeDecl();
if (auto *ownerClass = dyn_cast<ClassDecl>(ownerNominal))
baseTy = baseTy->getSuperclassForDecl(ownerClass);
if (auto *ownerClass = dyn_cast<ClassDecl>(ownerNominal)) {
baseTy = baseTy->getSuperclassForDecl(ownerClass,
/*usesArchetypes=*/genericEnv != nullptr);
}
// Gather all of the substitutions for all levels of generic arguments.
auto params = genericSig.getGenericParams();

View File

@@ -645,6 +645,8 @@ createDesignatedInitOverride(ClassDecl *classDecl,
auto genericSig = ctx.getOverrideGenericSignature(
superclassDecl, classDecl, superclassCtorSig, genericParams);
assert(!subMap.hasArchetypes());
if (superclassCtorSig) {
auto *genericEnv = genericSig.getGenericEnvironment();