Skip to content

Commit e971f81

Browse files
author
Sima Nerush
committed
Use countType and add an additional tuple check
1 parent f9e0007 commit e971f81

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7754,12 +7754,17 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
77547754
// number of elements, record a fix.
77557755
auto *loc = getConstraintLocator(locator);
77567756
if (loc->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
7757-
if (auto paramPack = simplifyType(type2, flags)->getAs<PackType>()) {
7758-
if (type1->getAs<TupleType>()->getNumElements() ==
7759-
paramPack->getNumElements()) {
7760-
if (recordFix(DestructureTupleToMatchPackExpansionParameter::create(
7761-
*this, paramPack, loc))) {
7762-
return getTypeMatchFailure(loc);
7757+
if (auto packExpansion = type2->getAs<PackExpansionType>()) {
7758+
auto countType = simplifyType(packExpansion->getCountType(), flags);
7759+
if (auto paramPack = countType->getAs<PackType>()) {
7760+
if (auto *tuple = type1->getAs<TupleType>()) {
7761+
if (tuple->getNumElements() == paramPack->getNumElements()) {
7762+
if (recordFix(
7763+
DestructureTupleToMatchPackExpansionParameter::create(
7764+
*this, paramPack, loc))) {
7765+
return getTypeMatchFailure(loc);
7766+
}
7767+
}
77637768
}
77647769
}
77657770
}

0 commit comments

Comments
 (0)