@@ -2675,7 +2675,7 @@ template<typename ImplClass>
26752675void
26762676SILCloner<ImplClass>::visitOpenExistentialAddrInst(OpenExistentialAddrInst *Inst) {
26772677 // Create a new archetype for this opened existential type.
2678- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2678+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
26792679
26802680 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
26812681 recordClonedInstruction (
@@ -2688,7 +2688,7 @@ template <typename ImplClass>
26882688void SILCloner<ImplClass>::visitOpenExistentialValueInst(
26892689 OpenExistentialValueInst *Inst) {
26902690 // Create a new archetype for this opened existential type.
2691- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2691+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
26922692
26932693 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
26942694 recordClonedInstruction (
@@ -2704,14 +2704,7 @@ template<typename ImplClass>
27042704void
27052705SILCloner<ImplClass>::
27062706visitOpenExistentialMetatypeInst (OpenExistentialMetatypeInst *Inst) {
2707- // Create a new archetype for this opened existential type.
2708- auto openedType = Inst->getType ().getASTType ();
2709- auto exType = Inst->getOperand ()->getType ().getASTType ();
2710- while (auto exMetatype = dyn_cast<ExistentialMetatypeType>(exType)) {
2711- exType = exMetatype->getExistentialInstanceType ()->getCanonicalType ();
2712- openedType = cast<MetatypeType>(openedType).getInstanceType ();
2713- }
2714- remapRootOpenedType (cast<OpenedArchetypeType>(openedType));
2707+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
27152708
27162709 if (!Inst->getOperand ()->getType ().canUseExistentialRepresentation (
27172710 ExistentialRepresentation::Class)) {
@@ -2735,7 +2728,7 @@ void
27352728SILCloner<ImplClass>::
27362729visitOpenExistentialRefInst (OpenExistentialRefInst *Inst) {
27372730 // Create a new archetype for this opened existential type.
2738- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2731+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
27392732
27402733 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
27412734 recordClonedInstruction (
@@ -2752,7 +2745,7 @@ void
27522745SILCloner<ImplClass>::
27532746visitOpenExistentialBoxInst (OpenExistentialBoxInst *Inst) {
27542747 // Create a new archetype for this opened existential type.
2755- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2748+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
27562749
27572750 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
27582751 recordClonedInstruction (Inst, getBuilder ().createOpenExistentialBox (
@@ -2766,7 +2759,7 @@ void
27662759SILCloner<ImplClass>::
27672760visitOpenExistentialBoxValueInst (OpenExistentialBoxValueInst *Inst) {
27682761 // Create a new archetype for this opened existential type.
2769- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2762+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
27702763
27712764 getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
27722765 recordClonedInstruction (
0 commit comments