@@ -13499,6 +13499,17 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13499
13499
: SolutionKind::Solved;
13500
13500
};
13501
13501
13502
+ auto recordShapeMismatchFix = [&]() -> SolutionKind {
13503
+ unsigned impact = 1;
13504
+ if (locator.endsWith<LocatorPathElt::AnyRequirement>())
13505
+ impact = assessRequirementFailureImpact(*this, shape1, locator);
13506
+
13507
+ return recordShapeFix(
13508
+ SkipSameShapeRequirement::create(*this, type1, type2,
13509
+ getConstraintLocator(locator)),
13510
+ impact);
13511
+ };
13512
+
13502
13513
// Let's check whether we can produce a tailored fix for argument/parameter
13503
13514
// mismatches.
13504
13515
if (locator.endsWith<LocatorPathElt::PackShape>()) {
@@ -13518,8 +13529,15 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13518
13529
auto argLoc =
13519
13530
loc->castLastElementTo<LocatorPathElt::ApplyArgToParam>();
13520
13531
13521
- auto argPack = type1->castTo<PackType>();
13522
- auto paramPack = type2->castTo<PackType>();
13532
+ if (type1->getAs<PackArchetypeType>() &&
13533
+ type2->getAs<PackArchetypeType>())
13534
+ return recordShapeMismatchFix();
13535
+
13536
+ auto argPack = type1->getAs<PackType>();
13537
+ auto paramPack = type2->getAs<PackType>();
13538
+
13539
+ if (!(argPack && paramPack))
13540
+ return SolutionKind::Error;
13523
13541
13524
13542
// Tailed diagnostic to explode tuples.
13525
13543
// FIXME: This is very similar to
@@ -13578,14 +13596,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifySameShapeConstraint(
13578
13596
}
13579
13597
}
13580
13598
13581
- unsigned impact = 1;
13582
- if (locator.endsWith<LocatorPathElt::AnyRequirement>())
13583
- impact = assessRequirementFailureImpact(*this, shape1, locator);
13584
-
13585
- return recordShapeFix(
13586
- SkipSameShapeRequirement::create(*this, type1, type2,
13587
- getConstraintLocator(locator)),
13588
- impact);
13599
+ return recordShapeMismatchFix();
13589
13600
}
13590
13601
13591
13602
return SolutionKind::Error;
0 commit comments