@@ -13479,6 +13479,17 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13479
13479
: SolutionKind::Solved;
13480
13480
};
13481
13481
13482
+ auto recordShapeMismatchFix = [&]() -> SolutionKind {
13483
+ unsigned impact = 1;
13484
+ if (locator.endsWith<LocatorPathElt::AnyRequirement>())
13485
+ impact = assessRequirementFailureImpact(*this, shape1, locator);
13486
+
13487
+ return recordShapeFix(
13488
+ SkipSameShapeRequirement::create(*this, type1, type2,
13489
+ getConstraintLocator(locator)),
13490
+ impact);
13491
+ };
13492
+
13482
13493
// Let's check whether we can produce a tailored fix for argument/parameter
13483
13494
// mismatches.
13484
13495
if (locator.endsWith<LocatorPathElt::PackShape>()) {
@@ -13498,8 +13509,15 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13498
13509
auto argLoc =
13499
13510
loc->castLastElementTo<LocatorPathElt::ApplyArgToParam>();
13500
13511
13501
- auto argPack = type1->castTo<PackType>();
13502
- auto paramPack = type2->castTo<PackType>();
13512
+ if (type1->getAs<PackArchetypeType>() &&
13513
+ type2->getAs<PackArchetypeType>())
13514
+ return recordShapeMismatchFix();
13515
+
13516
+ auto argPack = type1->getAs<PackType>();
13517
+ auto paramPack = type2->getAs<PackType>();
13518
+
13519
+ if (!(argPack && paramPack))
13520
+ return SolutionKind::Error;
13503
13521
13504
13522
// Tailed diagnostic to explode tuples.
13505
13523
// FIXME: This is very similar to
@@ -13558,14 +13576,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13558
13576
}
13559
13577
}
13560
13578
13561
- unsigned impact = 1;
13562
- if (locator.endsWith<LocatorPathElt::AnyRequirement>())
13563
- impact = assessRequirementFailureImpact(*this, shape1, locator);
13564
-
13565
- return recordShapeFix(
13566
- SkipSameShapeRequirement::create(*this, type1, type2,
13567
- getConstraintLocator(locator)),
13568
- impact);
13579
+ return recordShapeMismatchFix();
13569
13580
}
13570
13581
13571
13582
return SolutionKind::Error;
0 commit comments