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

@@ -253,9 +253,9 @@ public:
return asImpl().remapASTType(ty);
}
void remapOpenedType(CanArchetypeType archetypeTy) {
void remapOpenedType(CanOpenedArchetypeType archetypeTy) {
auto existentialTy = archetypeTy->getOpenedExistentialType()->getCanonicalType();
auto replacementTy = ArchetypeType::getOpened(getOpASTType(existentialTy));
auto replacementTy = OpenedArchetypeType::get(getOpASTType(existentialTy));
registerOpenedExistentialRemapping(archetypeTy, replacementTy);
}
@@ -1878,7 +1878,7 @@ template<typename ImplClass>
void
SILCloner<ImplClass>::visitOpenExistentialAddrInst(OpenExistentialAddrInst *Inst) {
// Create a new archetype for this opened existential type.
remapOpenedType(Inst->getType().castTo<ArchetypeType>());
remapOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(
@@ -1891,7 +1891,7 @@ template <typename ImplClass>
void SILCloner<ImplClass>::visitOpenExistentialValueInst(
OpenExistentialValueInst *Inst) {
// Create a new archetype for this opened existential type.
remapOpenedType(Inst->getType().castTo<ArchetypeType>());
remapOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(Inst, getBuilder().createOpenExistentialValue(
@@ -1911,7 +1911,7 @@ visitOpenExistentialMetatypeInst(OpenExistentialMetatypeInst *Inst) {
exType = exMetatype.getInstanceType();
openedType = cast<MetatypeType>(openedType).getInstanceType();
}
remapOpenedType(cast<ArchetypeType>(openedType));
remapOpenedType(cast<OpenedArchetypeType>(openedType));
if (!Inst->getOperand()->getType().canUseExistentialRepresentation(
Inst->getModule(), ExistentialRepresentation::Class)) {
@@ -1935,7 +1935,7 @@ void
SILCloner<ImplClass>::
visitOpenExistentialRefInst(OpenExistentialRefInst *Inst) {
// Create a new archetype for this opened existential type.
remapOpenedType(Inst->getType().castTo<ArchetypeType>());
remapOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(Inst, getBuilder().createOpenExistentialRef(
@@ -1949,7 +1949,7 @@ void
SILCloner<ImplClass>::
visitOpenExistentialBoxInst(OpenExistentialBoxInst *Inst) {
// Create a new archetype for this opened existential type.
remapOpenedType(Inst->getType().castTo<ArchetypeType>());
remapOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(Inst, getBuilder().createOpenExistentialBox(
@@ -1963,7 +1963,7 @@ void
SILCloner<ImplClass>::
visitOpenExistentialBoxValueInst(OpenExistentialBoxValueInst *Inst) {
// Create a new archetype for this opened existential type.
remapOpenedType(Inst->getType().castTo<ArchetypeType>());
remapOpenedType(Inst->getType().castTo<OpenedArchetypeType>());
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
recordClonedInstruction(Inst, getBuilder().createOpenExistentialBoxValue(