@@ -13536,33 +13536,34 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
1353613536 auto argLoc =
1353713537 loc->castLastElementTo<LocatorPathElt::ApplyArgToParam>();
1353813538
13539- if (type1->getAs <PackArchetypeType>() &&
13540- type2->getAs <PackArchetypeType>())
13539+ if (type1->is <PackArchetypeType>() &&
13540+ type2->is <PackArchetypeType>())
1354113541 return recordShapeMismatchFix();
1354213542
13543- auto argPack = type1->getAs<PackType>();
13544- auto paramPack = type2->getAs<PackType>();
13545-
13546- if (!(argPack && paramPack))
13547- return SolutionKind::Error;
13543+ auto numArgs = (shape1->is<PackType>()
13544+ ? shape1->castTo<PackType>()->getNumElements()
13545+ : 1);
13546+ auto numParams = (shape2->is<PackType>()
13547+ ? shape2->castTo<PackType>()->getNumElements()
13548+ : 1);
1354813549
1354913550 // Tailed diagnostic to explode tuples.
1355013551 // FIXME: This is very similar to
1355113552 // 'cannot_convert_single_tuple_into_multiple_arguments'; can we emit
1355213553 // both of these in the same place?
13553- if (argPack->getNumElements() == 1) {
13554- if (argPack->getElementType(0) ->is<TupleType>() &&
13555- paramPack->getNumElements() >= 1) {
13554+ if (numArgs == 1) {
13555+ if (type1 ->is<TupleType>() &&
13556+ numParams >= 1) {
1355613557 return recordShapeFix(
1355713558 DestructureTupleToMatchPackExpansionParameter::create(
13558- *this, paramPack, loc),
13559- /*impact=*/2 * paramPack->getNumElements());
13559+ *this,
13560+ (type2->is<PackType>()
13561+ ? type2->castTo<PackType>()
13562+ : PackType::getSingletonPackExpansion(type2)), loc),
13563+ /*impact=*/2 * numParams);
1356013564 }
1356113565 }
1356213566
13563- auto numArgs = shape1->castTo<PackType>()->getNumElements();
13564- auto numParams = shape2->castTo<PackType>()->getNumElements();
13565-
1356613567 // Drops `ApplyArgToParam` and left with `ApplyArgument`.
1356713568 path.pop_back();
1356813569
0 commit comments