Push ArchetypeType's API down to subclasses.

And clean up code that conditionally works only with certain kinds of archetype along the way.
This commit is contained in:
Joe Groff
2018-12-12 13:26:16 -08:00
parent 4f0f11f6bb
commit 89979137fc
37 changed files with 265 additions and 328 deletions

View File

@@ -202,7 +202,7 @@ static ManagedValue emitTransformExistential(SILGenFunction &SGF,
ArchetypeType *openedArchetype = nullptr;
if (inputType->isAnyExistentialType()) {
CanType openedType = ArchetypeType::getAnyOpened(inputType);
CanType openedType = OpenedArchetypeType::getAny(inputType);
SILType loweredOpenedType = SGF.getLoweredType(openedType);
// Unwrap zero or more metatype levels
@@ -575,7 +575,7 @@ ManagedValue Transform::transform(ManagedValue v,
auto layout = instanceType.getExistentialLayout();
if (layout.explicitSuperclass) {
CanType openedType = ArchetypeType::getAnyOpened(inputSubstType);
CanType openedType = OpenedArchetypeType::getAny(inputSubstType);
SILType loweredOpenedType = SGF.getLoweredType(openedType);
// Unwrap zero or more metatype levels
@@ -2889,7 +2889,7 @@ static void buildThunkBody(SILGenFunction &SGF, SILLocation loc,
static CanGenericSignature
buildThunkSignature(SILGenFunction &SGF,
bool inheritGenericSig,
ArchetypeType *openedExistential,
OpenedArchetypeType *openedExistential,
GenericEnvironment *&genericEnv,
SubstitutionMap &contextSubs,
SubstitutionMap &interfaceSubs,
@@ -2988,16 +2988,17 @@ CanSILFunctionType SILGenFunction::buildThunkType(
// Does the thunk type involve archetypes other than opened existentials?
bool hasArchetypes = false;
// Does the thunk type involve an open existential type?
CanArchetypeType openedExistential;
CanOpenedArchetypeType openedExistential;
auto archetypeVisitor = [&](CanType t) {
if (auto archetypeTy = dyn_cast<ArchetypeType>(t)) {
if (archetypeTy->getOpenedExistentialType()) {
if (auto opened = dyn_cast<OpenedArchetypeType>(archetypeTy)) {
assert((openedExistential == CanArchetypeType() ||
openedExistential == archetypeTy) &&
openedExistential == opened) &&
"one too many open existentials");
openedExistential = archetypeTy;
} else
openedExistential = opened;
} else {
hasArchetypes = true;
}
}
};