Split subclasses out of ArchetypeType.

Context archetypes and opened existential archetypes differ in a number of details, and this simplifies the overlapping storage of the kind-specific fields. This should be NFC; for now, this doesn't change the interface of ArchetypeType, but should allow some refinements of how the special handling of certain archetypes are handled.
This commit is contained in:
Joe Groff
2018-12-11 20:22:24 -08:00
parent 7732b984bd
commit f1648a1b3e
13 changed files with 295 additions and 138 deletions

View File

@@ -1020,7 +1020,7 @@ static void bindArchetypesFromContext(
ConstraintLocator *locatorPtr,
const OpenedTypeMap &replacements) {
auto bindContextArchetype = [&](Type paramTy, Type contextTy) {
auto bindPrimaryArchetype = [&](Type paramTy, Type contextTy) {
auto found = replacements.find(cast<GenericTypeParamType>(
paramTy->getCanonicalType()));
@@ -1044,7 +1044,7 @@ static void bindArchetypesFromContext(
if (parentDC != outerDC && parentDC->getSelfProtocolDecl()) {
auto selfTy = parentDC->getSelfInterfaceType();
auto contextTy = cs.TC.Context.TheUnresolvedType;
bindContextArchetype(selfTy, contextTy);
bindPrimaryArchetype(selfTy, contextTy);
}
continue;
}
@@ -1056,7 +1056,7 @@ static void bindArchetypesFromContext(
for (auto *paramTy : genericSig->getGenericParams()) {
Type contextTy = cs.DC->mapTypeIntoContext(paramTy);
bindContextArchetype(paramTy, contextTy);
bindPrimaryArchetype(paramTy, contextTy);
}
break;