@@ -586,30 +586,8 @@ case TypeKind::Id:
586
586
}
587
587
588
588
case TypeKind::PackExpansion: {
589
- auto expand = cast<PackExpansionType>(base);
590
-
591
- // Substitution completely replaces this.
592
-
593
- Type transformedPat = doIt (expand->getPatternType (), pos);
594
- if (!transformedPat)
595
- return Type ();
596
-
597
- Type transformedCount = doIt (expand->getCountType (), TypePosition::Shape);
598
- if (!transformedCount)
599
- return Type ();
600
-
601
- if (transformedPat.getPointer () == expand->getPatternType ().getPointer () &&
602
- transformedCount.getPointer () == expand->getCountType ().getPointer ())
603
- return t;
604
-
605
- // // If we transform the count to a pack type, expand the pattern.
606
- // // This is necessary because of how we piece together types in
607
- // // the constraint system.
608
- // if (auto countPack = transformedCount->getAs<PackType>()) {
609
- // return PackExpansionType::expand(transformedPat, countPack);
610
- // }
611
-
612
- return PackExpansionType::get (transformedPat, transformedCount);
589
+ auto *expand = cast<PackExpansionType>(base);
590
+ return asDerived ().transformPackExpansion (expand, pos);
613
591
}
614
592
615
593
case TypeKind::PackElement: {
@@ -1005,8 +983,26 @@ case TypeKind::Id:
1005
983
CanType transformSILField (CanType fieldTy, TypePosition pos) {
1006
984
return doIt (fieldTy, pos)->getCanonicalType ();
1007
985
}
986
+
987
+ Type transformPackExpansion (PackExpansionType *expand, TypePosition pos) {
988
+ // Substitution completely replaces this.
989
+
990
+ Type transformedPat = doIt (expand->getPatternType (), pos);
991
+ if (!transformedPat)
992
+ return Type ();
993
+
994
+ Type transformedCount = doIt (expand->getCountType (), TypePosition::Shape);
995
+ if (!transformedCount)
996
+ return Type ();
997
+
998
+ if (transformedPat.getPointer () == expand->getPatternType ().getPointer () &&
999
+ transformedCount.getPointer () == expand->getCountType ().getPointer ())
1000
+ return expand;
1001
+
1002
+ return PackExpansionType::get (transformedPat, transformedCount);
1003
+ }
1008
1004
};
1009
1005
1010
1006
}
1011
1007
1012
- #endif
1008
+ #endif
0 commit comments