@@ -1965,12 +1965,7 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
1965
1965
Type type2, Expr *anchor,
1966
1966
ArrayRef<LocatorPathElt> path) {
1967
1967
// Can't fix not yet properly resolved types.
1968
- if (type1->hasTypeVariable () || type2->hasTypeVariable ())
1969
- return nullptr ;
1970
-
1971
- // If dependent members are present here it's because
1972
- // base doesn't conform to associated type's protocol.
1973
- if (type1->hasDependentMember () || type2->hasDependentMember ())
1968
+ if (type1->isTypeVariableOrMember () || type2->isTypeVariableOrMember ())
1974
1969
return nullptr ;
1975
1970
1976
1971
auto req = path.back ();
@@ -1999,9 +1994,9 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
1999
1994
return SkipSuperclassRequirement::create (cs, type1, type2, reqLoc);
2000
1995
}
2001
1996
2002
- case RequirementKind::Conformance:
2003
1997
case RequirementKind::Layout:
2004
- llvm_unreachable (" conformance requirements are handled elsewhere" );
1998
+ case RequirementKind::Conformance:
1999
+ return MissingConformance::forRequirement (cs, type1, type2, reqLoc);
2005
2000
}
2006
2001
}
2007
2002
@@ -2157,6 +2152,11 @@ bool ConstraintSystem::repairFailures(
2157
2152
2158
2153
case ConstraintLocator::TypeParameterRequirement:
2159
2154
case ConstraintLocator::ConditionalRequirement: {
2155
+ // If dependent members are present here it's because
2156
+ // base doesn't conform to associated type's protocol.
2157
+ if (lhs->hasDependentMember () || rhs->hasDependentMember ())
2158
+ break ;
2159
+
2160
2160
if (auto *fix = fixRequirementFailure (*this , lhs, rhs, anchor, path))
2161
2161
conversionsOrFixes.push_back (fix);
2162
2162
break ;
@@ -3380,23 +3380,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
3380
3380
3381
3381
if (path.back ().isTypeParameterRequirement () ||
3382
3382
path.back ().isConditionalRequirement ()) {
3383
- if (path.back ().isConditionalRequirement ()) {
3384
- // Drop 'conditional requirement' element, remainder
3385
- // of the path is going to point to type requirement
3386
- // this conditional comes from.
3387
- auto reqPath = ArrayRef<LocatorPathElt>(path).drop_back ();
3388
- // Underlying conformance requirement is itself fixed,
3389
- // this wouldn't lead to a right solution.
3390
- if (hasFixFor (getConstraintLocator (anchor, reqPath,
3391
- /* summaryFlags=*/ 0 )))
3392
- return SolutionKind::Error;
3383
+ if (auto *fix = fixRequirementFailure (
3384
+ *this , type, protocol->getDeclaredType (), anchor, path)) {
3385
+ if (!recordFix (fix))
3386
+ return SolutionKind::Solved;
3393
3387
}
3394
-
3395
- auto *fix = MissingConformance::forRequirement (
3396
- *this , type, protocol->getDeclaredType (),
3397
- getConstraintLocator (locator));
3398
- if (!recordFix (fix))
3399
- return SolutionKind::Solved;
3400
3388
}
3401
3389
3402
3390
// If this is an implicit Hashable conformance check generated for each
@@ -6545,8 +6533,10 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix) {
6545
6533
// Always useful, unless duplicate of exactly the same fix and location.
6546
6534
// This situation might happen when the same fix kind is applicable to
6547
6535
// different overload choices.
6548
- if (!hasFixFor (fix->getLocator ()))
6549
- Fixes.push_back (fix);
6536
+ if (hasFixFor (fix->getLocator ()))
6537
+ return false ;
6538
+
6539
+ Fixes.push_back (fix);
6550
6540
} else {
6551
6541
// Only useful to record if no pre-existing fix in the subexpr tree.
6552
6542
llvm::SmallDenseSet<Expr *> fixExprs;
0 commit comments