@@ -13624,33 +13624,34 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13624
13624
auto argLoc =
13625
13625
loc->castLastElementTo<LocatorPathElt::ApplyArgToParam>();
13626
13626
13627
- if (type1->getAs <PackArchetypeType>() &&
13628
- type2->getAs <PackArchetypeType>())
13627
+ if (type1->is <PackArchetypeType>() &&
13628
+ type2->is <PackArchetypeType>())
13629
13629
return recordShapeMismatchFix();
13630
13630
13631
- auto argPack = type1->getAs<PackType>();
13632
- auto paramPack = type2->getAs<PackType>();
13633
-
13634
- if (!(argPack && paramPack))
13635
- return SolutionKind::Error;
13631
+ auto numArgs = (shape1->is<PackType>()
13632
+ ? shape1->castTo<PackType>()->getNumElements()
13633
+ : 1);
13634
+ auto numParams = (shape2->is<PackType>()
13635
+ ? shape2->castTo<PackType>()->getNumElements()
13636
+ : 1);
13636
13637
13637
13638
// Tailed diagnostic to explode tuples.
13638
13639
// FIXME: This is very similar to
13639
13640
// 'cannot_convert_single_tuple_into_multiple_arguments'; can we emit
13640
13641
// both of these in the same place?
13641
- if (argPack->getNumElements() == 1) {
13642
- if (argPack->getElementType(0) ->is<TupleType>() &&
13643
- paramPack->getNumElements() >= 1) {
13642
+ if (numArgs == 1) {
13643
+ if (type1 ->is<TupleType>() &&
13644
+ numParams >= 1) {
13644
13645
return recordShapeFix(
13645
13646
DestructureTupleToMatchPackExpansionParameter::create(
13646
- *this, paramPack, loc),
13647
- /*impact=*/2 * paramPack->getNumElements());
13647
+ *this,
13648
+ (type2->is<PackType>()
13649
+ ? type2->castTo<PackType>()
13650
+ : PackType::getSingletonPackExpansion(type2)), loc),
13651
+ /*impact=*/2 * numParams);
13648
13652
}
13649
13653
}
13650
13654
13651
- auto numArgs = shape1->castTo<PackType>()->getNumElements();
13652
- auto numParams = shape2->castTo<PackType>()->getNumElements();
13653
-
13654
13655
// Drops `ApplyArgToParam` and left with `ApplyArgument`.
13655
13656
path.pop_back();
13656
13657
0 commit comments