@@ -1612,29 +1612,22 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
1612
1612
if (type1->hasDependentMember () || type2->hasDependentMember ())
1613
1613
return nullptr ;
1614
1614
1615
- auto reqPath = path.take_back (2 );
1616
- auto req = reqPath.back ();
1617
-
1618
- ConstraintLocator *reqLoc = nullptr ;
1615
+ auto req = path.back ();
1619
1616
if (req.isConditionalRequirement ()) {
1620
1617
// path is - ... -> open generic -> type req # -> cond req #,
1621
1618
// to identify type requirement we only need `open generic -> type req #`
1622
1619
// part, because that's how fixes for type requirements are recorded.
1623
- reqPath = path.drop_back (). take_back ( 2 );
1620
+ auto reqPath = path.drop_back ();
1624
1621
// If underlying conformance requirement has been fixed,
1625
1622
// then there is no reason to fix up conditional requirements.
1626
1623
if (cs.hasFixFor (cs.getConstraintLocator (anchor, reqPath,
1627
1624
/* summaryFlags=*/ 0 )))
1628
1625
return nullptr ;
1629
-
1630
- // For conditional requirements we need a full path.
1631
- reqLoc = cs.getConstraintLocator (anchor, path, /* summaryFlags=*/ 0 );
1632
- } else {
1633
- // Build simplified locator which only contains anchor and requirement info.
1634
- reqLoc = cs.getConstraintLocator (anchor, reqPath,
1635
- /* summaryFlags=*/ 0 );
1636
1626
}
1637
1627
1628
+ auto *reqLoc = cs.getConstraintLocator (anchor, path,
1629
+ /* summaryFlags=*/ 0 );
1630
+
1638
1631
auto reqKind = static_cast <RequirementKind>(req.getValue2 ());
1639
1632
switch (reqKind) {
1640
1633
case RequirementKind::SameType: {
@@ -2789,32 +2782,20 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
2789
2782
2790
2783
if (path.back ().isTypeParameterRequirement () ||
2791
2784
path.back ().isConditionalRequirement ()) {
2792
- ConstraintLocator *reqLoc = nullptr ;
2793
2785
if (path.back ().isConditionalRequirement ()) {
2794
- // Drop 'conditional requirement' element remainder
2786
+ // Drop 'conditional requirement' element, remainder
2795
2787
// of the path is going to point to type requirement
2796
2788
// this conditional comes from.
2797
2789
auto reqPath = ArrayRef<LocatorPathElt>(path).drop_back ();
2798
2790
// Underlying conformance requirement is itself fixed,
2799
2791
// this wouldn't lead to a right solution.
2800
- if (hasFixFor (getConstraintLocator (anchor, reqPath. take_back ( 2 ) ,
2792
+ if (hasFixFor (getConstraintLocator (anchor, reqPath,
2801
2793
/* summaryFlags=*/ 0 )))
2802
2794
return SolutionKind::Error;
2803
-
2804
- // For conditional requirements we need complete path, which includes
2805
- // type requirement position, to be able to fetch conformance later.
2806
- reqLoc = getConstraintLocator (locator);
2807
- } else {
2808
- // Let's strip all of the unnecessary information from locator,
2809
- // diagnostics only care about anchor - to lookup type,
2810
- // generic signature where requirement comes from, and
2811
- // what was the requirement# which is not satisfied.
2812
- auto reqPath = ArrayRef<LocatorPathElt>(path).take_back (2 );
2813
- reqLoc = getConstraintLocator (anchor, reqPath,
2814
- /* summaryFlags=*/ 0 );
2815
2795
}
2816
2796
2817
- auto *fix = MissingConformance::create (*this , type, protocol, reqLoc);
2797
+ auto *fix = MissingConformance::create (*this , type, protocol,
2798
+ getConstraintLocator (locator));
2818
2799
if (!recordFix (fix))
2819
2800
return SolutionKind::Solved;
2820
2801
}
0 commit comments