@@ -13536,33 +13536,34 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13536
13536
auto argLoc =
13537
13537
loc->castLastElementTo<LocatorPathElt::ApplyArgToParam>();
13538
13538
13539
- if (type1->getAs <PackArchetypeType>() &&
13540
- type2->getAs <PackArchetypeType>())
13539
+ if (type1->is <PackArchetypeType>() &&
13540
+ type2->is <PackArchetypeType>())
13541
13541
return recordShapeMismatchFix();
13542
13542
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);
13548
13549
13549
13550
// Tailed diagnostic to explode tuples.
13550
13551
// FIXME: This is very similar to
13551
13552
// 'cannot_convert_single_tuple_into_multiple_arguments'; can we emit
13552
13553
// 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) {
13556
13557
return recordShapeFix(
13557
13558
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);
13560
13564
}
13561
13565
}
13562
13566
13563
- auto numArgs = shape1->castTo<PackType>()->getNumElements();
13564
- auto numParams = shape2->castTo<PackType>()->getNumElements();
13565
-
13566
13567
// Drops `ApplyArgToParam` and left with `ApplyArgument`.
13567
13568
path.pop_back();
13568
13569
0 commit comments