Skip to content

Commit f4a082d

Browse files
committed
[ConstraintSystem] TypeSimplifier: If pattern and shape are packs - produce pattern type
The `transformWithPosition` would handle its flattening.
1 parent 8a39f3f commit f4a082d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3793,13 +3793,14 @@ struct TypeSimplifier {
37933793
}
37943794

37953795
if (auto expansion = dyn_cast<PackExpansionType>(type.getPointer())) {
3796+
auto patternType = expansion->getPatternType();
37963797
// First, let's check whether pattern type has all of the type variables
37973798
// that represent packs resolved, otherwise we don't have enough information
37983799
// to flatten this pack expansion type.
37993800
//
38003801
// Note that we don't actually need to do deep transformation here
38013802
// because pack variables can only appear in structural positions.
3802-
if (expansion->getPatternType().findIf([&](Type type) {
3803+
if (patternType.findIf([&](Type type) {
38033804
if (auto *typeVar = type->getAs<TypeVariableType>()) {
38043805
if (typeVar->getImpl().canBindToPack())
38053806
return GetFixedTypeFn(typeVar)->is<TypeVariableType>();
@@ -3813,6 +3814,12 @@ struct TypeSimplifier {
38133814
auto countType = expansion->getCountType().transform(
38143815
TypeSimplifier(CS, GetFixedTypeFn));
38153816

3817+
// If both pattern and count are resolves, let's just return
3818+
// the pattern type for `transformWithPosition` to take care
3819+
// of the rest.
3820+
if (patternType->is<PackType>() && countType->is<PackType>())
3821+
return patternType;
3822+
38163823
if (auto countPack = countType->getAs<PackType>()) {
38173824
SmallVector<Type, 4> elts;
38183825
ActivePackExpansions.push_back({false, 0});

0 commit comments

Comments
 (0)