@@ -2675,7 +2675,7 @@ template<typename ImplClass>
2675
2675
void
2676
2676
SILCloner<ImplClass>::visitOpenExistentialAddrInst(OpenExistentialAddrInst *Inst) {
2677
2677
// Create a new archetype for this opened existential type.
2678
- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2678
+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
2679
2679
2680
2680
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
2681
2681
recordClonedInstruction (
@@ -2688,7 +2688,7 @@ template <typename ImplClass>
2688
2688
void SILCloner<ImplClass>::visitOpenExistentialValueInst(
2689
2689
OpenExistentialValueInst *Inst) {
2690
2690
// Create a new archetype for this opened existential type.
2691
- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2691
+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
2692
2692
2693
2693
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
2694
2694
recordClonedInstruction (
@@ -2704,14 +2704,7 @@ template<typename ImplClass>
2704
2704
void
2705
2705
SILCloner<ImplClass>::
2706
2706
visitOpenExistentialMetatypeInst (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 ());
2715
2708
2716
2709
if (!Inst->getOperand ()->getType ().canUseExistentialRepresentation (
2717
2710
ExistentialRepresentation::Class)) {
@@ -2735,7 +2728,7 @@ void
2735
2728
SILCloner<ImplClass>::
2736
2729
visitOpenExistentialRefInst (OpenExistentialRefInst *Inst) {
2737
2730
// Create a new archetype for this opened existential type.
2738
- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2731
+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
2739
2732
2740
2733
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
2741
2734
recordClonedInstruction (
@@ -2752,7 +2745,7 @@ void
2752
2745
SILCloner<ImplClass>::
2753
2746
visitOpenExistentialBoxInst (OpenExistentialBoxInst *Inst) {
2754
2747
// Create a new archetype for this opened existential type.
2755
- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2748
+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
2756
2749
2757
2750
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
2758
2751
recordClonedInstruction (Inst, getBuilder ().createOpenExistentialBox (
@@ -2766,7 +2759,7 @@ void
2766
2759
SILCloner<ImplClass>::
2767
2760
visitOpenExistentialBoxValueInst (OpenExistentialBoxValueInst *Inst) {
2768
2761
// Create a new archetype for this opened existential type.
2769
- remapRootOpenedType (Inst->getType (). castTo <OpenedArchetypeType> ());
2762
+ remapRootOpenedType (Inst->getDefinedOpenedArchetype ());
2770
2763
2771
2764
getBuilder ().setCurrentDebugScope (getOpScope (Inst->getDebugScope ()));
2772
2765
recordClonedInstruction (
0 commit comments