@@ -2712,74 +2712,76 @@ TypeConverter::getTypeLowering(AbstractionPattern origType,
2712
2712
2713
2713
#ifndef NDEBUG
2714
2714
bool TypeConverter::visitAggregateLeaves (
2715
- Lowering::AbstractionPattern origType, Type substType,
2715
+ Lowering::AbstractionPattern origType, CanType substType,
2716
2716
TypeExpansionContext context,
2717
- std::function<bool (Type , Lowering::AbstractionPattern, ValueDecl *,
2717
+ std::function<bool (CanType , Lowering::AbstractionPattern, ValueDecl *,
2718
2718
Optional<unsigned >)>
2719
2719
isLeafAggregate,
2720
- std::function<bool(Type , Lowering::AbstractionPattern, ValueDecl *,
2720
+ std::function<bool(CanType , Lowering::AbstractionPattern, ValueDecl *,
2721
2721
Optional<unsigned >)>
2722
2722
visit) {
2723
- llvm::SmallSet<std::tuple<TypeBase * , ValueDecl *, unsigned >, 16 > visited;
2723
+ llvm::SmallSet<std::tuple<CanType , ValueDecl *, unsigned >, 16 > visited;
2724
2724
llvm::SmallVector<
2725
- std::tuple<TypeBase * , AbstractionPattern, ValueDecl *, unsigned >, 16 >
2725
+ std::tuple<CanType , AbstractionPattern, ValueDecl *, unsigned >, 16 >
2726
2726
worklist;
2727
2727
auto insertIntoWorklist = [&visited,
2728
- &worklist](Type substTy, AbstractionPattern origTy,
2728
+ &worklist](CanType substTy,
2729
+ AbstractionPattern origTy,
2729
2730
ValueDecl *field,
2730
2731
Optional<unsigned > maybeIndex) -> bool {
2731
2732
unsigned index = maybeIndex.value_or (UINT_MAX);
2732
- if (!visited.insert ({substTy. getPointer () , field, index}).second )
2733
+ if (!visited.insert ({substTy, field, index}).second )
2733
2734
return false ;
2734
- worklist.push_back ({substTy. getPointer () , origTy, field, index});
2735
+ worklist.push_back ({substTy, origTy, field, index});
2735
2736
return true ;
2736
2737
};
2737
2738
auto popFromWorklist = [&worklist]()
2738
- -> std::tuple<Type , AbstractionPattern, ValueDecl *, Optional<unsigned >> {
2739
- TypeBase * ty;
2739
+ -> std::tuple<CanType , AbstractionPattern, ValueDecl *, Optional<unsigned >> {
2740
+ CanType ty;
2740
2741
AbstractionPattern origTy = AbstractionPattern::getOpaque ();
2741
2742
ValueDecl *field;
2742
2743
unsigned index;
2743
2744
std::tie (ty, origTy, field, index) = worklist.pop_back_val ();
2744
2745
Optional<unsigned > maybeIndex;
2745
2746
if (index != UINT_MAX)
2746
2747
maybeIndex = {index};
2747
- return {ty-> getCanonicalType () , origTy, field, index};
2748
+ return {ty, origTy, field, index};
2748
2749
};
2749
- auto isAggregate = [](Type ty) {
2750
- return ty->is <SILPackType>() || ty->is <TupleType>() || ty->getEnumOrBoundGenericEnum () ||
2751
- ty->getStructOrBoundGenericStruct ();
2750
+ auto isAggregate = [](CanType ty) {
2751
+ return isa<SILPackType>(ty) ||
2752
+ isa<TupleType>(ty) ||
2753
+ ty.getEnumOrBoundGenericEnum () ||
2754
+ ty.getStructOrBoundGenericStruct ();
2752
2755
};
2753
2756
insertIntoWorklist (substType, origType, nullptr , llvm::None);
2754
2757
while (!worklist.empty ()) {
2755
- Type ty;
2758
+ CanType ty;
2756
2759
AbstractionPattern origTy = AbstractionPattern::getOpaque ();
2757
2760
ValueDecl *field;
2758
2761
Optional<unsigned > index;
2759
2762
std::tie (ty, origTy, field, index) = popFromWorklist ();
2760
2763
if (isAggregate (ty) && !isLeafAggregate (ty, origTy, field, index)) {
2761
- if (auto packTy = ty-> getAs <SILPackType>()) {
2764
+ if (auto packTy = dyn_cast <SILPackType>(ty )) {
2762
2765
for (auto packIndex : indices (packTy->getElementTypes ())) {
2763
2766
auto origElementTy = origTy.getPackElementType (packIndex);
2764
- auto substElementTy =
2765
- packTy->getElementType (packIndex)->getCanonicalType ();
2767
+ auto substElementTy = packTy.getElementType (packIndex);
2766
2768
substElementTy =
2767
2769
computeLoweredRValueType (context, origElementTy, substElementTy);
2768
2770
insertIntoWorklist (substElementTy, origElementTy, nullptr ,
2769
2771
packIndex);
2770
2772
}
2771
- } else if (auto tupleTy = ty-> getAs <TupleType>()) {
2773
+ } else if (auto tupleTy = dyn_cast <TupleType>(ty )) {
2772
2774
unsigned tupleIndex = 0 ;
2773
2775
origTy.forEachExpandedTupleElement (
2774
- CanTupleType ( tupleTy) ,
2776
+ tupleTy,
2775
2777
[&](auto origElementTy, auto substElementTy, auto element) {
2776
2778
substElementTy =
2777
2779
substOpaqueTypesWithUnderlyingTypes (substElementTy, context);
2778
2780
insertIntoWorklist (substElementTy, origElementTy, nullptr ,
2779
2781
tupleIndex);
2780
2782
++tupleIndex;
2781
2783
});
2782
- } else if (auto *decl = ty-> getStructOrBoundGenericStruct ()) {
2784
+ } else if (auto *decl = ty. getStructOrBoundGenericStruct ()) {
2783
2785
for (auto *structField : decl->getStoredProperties ()) {
2784
2786
auto subMap = ty->getContextSubstitutionMap (&M, decl);
2785
2787
auto substFieldTy =
@@ -2794,7 +2796,7 @@ bool TypeConverter::visitAggregateLeaves(
2794
2796
insertIntoWorklist (substFieldTy, origFieldType, structField,
2795
2797
llvm::None);
2796
2798
}
2797
- } else if (auto *decl = ty-> getEnumOrBoundGenericEnum ()) {
2799
+ } else if (auto *decl = ty. getEnumOrBoundGenericEnum ()) {
2798
2800
auto subMap = ty->getContextSubstitutionMap (&M, decl);
2799
2801
for (auto *element : decl->getAllElements ()) {
2800
2802
if (!element->hasAssociatedValues ())
@@ -2827,16 +2829,17 @@ bool TypeConverter::visitAggregateLeaves(
2827
2829
}
2828
2830
2829
2831
void TypeConverter::verifyLowering (const TypeLowering &lowering,
2830
- AbstractionPattern origType, Type substType,
2832
+ AbstractionPattern origType,
2833
+ CanType substType,
2831
2834
TypeExpansionContext forExpansion) {
2832
2835
// Non-trivial lowerings should always be lexical unless all non-trivial
2833
2836
// fields are eager move.
2834
2837
if (!lowering.isTrivial () && !lowering.isLexical ()) {
2835
2838
if (lowering.getRecursiveProperties ().isInfinite ())
2836
2839
return ;
2837
- auto getLifetimeAnnotation = [](Type ty) -> LifetimeAnnotation {
2840
+ auto getLifetimeAnnotation = [](CanType ty) -> LifetimeAnnotation {
2838
2841
NominalTypeDecl *nominal;
2839
- if (!(nominal = ty-> getAnyNominal ()))
2842
+ if (!(nominal = ty. getAnyNominal ()))
2840
2843
return LifetimeAnnotation::None;
2841
2844
return nominal->getLifetimeAnnotation ();
2842
2845
};
@@ -2865,7 +2868,7 @@ void TypeConverter::verifyLowering(const TypeLowering &lowering,
2865
2868
2866
2869
// If the leaf is the whole type, verify that it is annotated
2867
2870
// @_eagerMove.
2868
- if (ty-> getCanonicalType () == substType-> getCanonicalType () )
2871
+ if (ty == substType)
2869
2872
return getLifetimeAnnotation (ty) == LifetimeAnnotation::EagerMove;
2870
2873
2871
2874
auto &tyLowering = getTypeLowering (origTy, ty, forExpansion);
0 commit comments