@@ -13531,33 +13531,34 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13531
13531
auto argLoc =
13532
13532
loc->castLastElementTo<LocatorPathElt::ApplyArgToParam>();
13533
13533
13534
- if (type1->getAs <PackArchetypeType>() &&
13535
- type2->getAs <PackArchetypeType>())
13534
+ if (type1->is <PackArchetypeType>() &&
13535
+ type2->is <PackArchetypeType>())
13536
13536
return recordShapeMismatchFix();
13537
13537
13538
- auto argPack = type1->getAs<PackType>();
13539
- auto paramPack = type2->getAs<PackType>();
13540
-
13541
- if (!(argPack && paramPack))
13542
- return SolutionKind::Error;
13538
+ auto numArgs = (shape1->is<PackType>()
13539
+ ? shape1->castTo<PackType>()->getNumElements()
13540
+ : 1);
13541
+ auto numParams = (shape2->is<PackType>()
13542
+ ? shape2->castTo<PackType>()->getNumElements()
13543
+ : 1);
13543
13544
13544
13545
// Tailed diagnostic to explode tuples.
13545
13546
// FIXME: This is very similar to
13546
13547
// 'cannot_convert_single_tuple_into_multiple_arguments'; can we emit
13547
13548
// both of these in the same place?
13548
- if (argPack->getNumElements() == 1) {
13549
- if (argPack->getElementType(0) ->is<TupleType>() &&
13550
- paramPack->getNumElements() >= 1) {
13549
+ if (numArgs == 1) {
13550
+ if (type1 ->is<TupleType>() &&
13551
+ numParams >= 1) {
13551
13552
return recordShapeFix(
13552
13553
DestructureTupleToMatchPackExpansionParameter::create(
13553
- *this, paramPack, loc),
13554
- /*impact=*/2 * paramPack->getNumElements());
13554
+ *this,
13555
+ (type2->is<PackType>()
13556
+ ? type2->castTo<PackType>()
13557
+ : PackType::getSingletonPackExpansion(type2)), loc),
13558
+ /*impact=*/2 * numParams);
13555
13559
}
13556
13560
}
13557
13561
13558
- auto numArgs = shape1->castTo<PackType>()->getNumElements();
13559
- auto numParams = shape2->castTo<PackType>()->getNumElements();
13560
-
13561
13562
// Drops `ApplyArgToParam` and left with `ApplyArgument`.
13562
13563
path.pop_back();
13563
13564
0 commit comments