Skip to content

Commit d7c3208

Browse files
committed
[CSSimplify] Handle presence of pack expansion if tuples and shape constraints
Tuple types cannot be matched until all pack expansion variables are resolved, the same is applicable to `shape of` constraints because the structure of the pack is not fully resolved in such cases.
1 parent 5340725 commit d7c3208

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6891,6 +6891,13 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
68916891
return true;
68926892
}
68936893

6894+
// Delay matching if one of the elements is unresolved pack
6895+
// expansion represented by a type variable.
6896+
if (auto *typeVar = element.getType()->getAs<TypeVariableType>()) {
6897+
if (typeVar->getImpl().isPackExpansion())
6898+
return true;
6899+
}
6900+
68946901
afterPack = element.getType()->is<PackExpansionType>();
68956902
}
68966903

@@ -13103,11 +13110,13 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyShapeOfConstraint(
1310313110
return formUnsolved();
1310413111

1310513112
// We can't compute a reduced shape if the input type still
13106-
// contains type variables that might bind to pack archetypes.
13113+
// contains type variables that might bind to pack archetypes
13114+
// or pack expansions.
1310713115
SmallPtrSet<TypeVariableType *, 2> typeVars;
1310813116
type1->getTypeVariables(typeVars);
1310913117
for (auto *typeVar : typeVars) {
13110-
if (typeVar->getImpl().canBindToPack())
13118+
if (typeVar->getImpl().canBindToPack() ||
13119+
typeVar->getImpl().isPackExpansion())
1311113120
return formUnsolved();
1311213121
}
1311313122

0 commit comments

Comments
 (0)