Skip to content

Commit 3b0ee99

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 8b3709e + b47215d commit 3b0ee99

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,12 +1965,7 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
19651965
Type type2, Expr *anchor,
19661966
ArrayRef<LocatorPathElt> path) {
19671967
// 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())
19741969
return nullptr;
19751970

19761971
auto req = path.back();
@@ -1999,9 +1994,9 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
19991994
return SkipSuperclassRequirement::create(cs, type1, type2, reqLoc);
20001995
}
20011996

2002-
case RequirementKind::Conformance:
20031997
case RequirementKind::Layout:
2004-
llvm_unreachable("conformance requirements are handled elsewhere");
1998+
case RequirementKind::Conformance:
1999+
return MissingConformance::forRequirement(cs, type1, type2, reqLoc);
20052000
}
20062001
}
20072002

@@ -2157,6 +2152,11 @@ bool ConstraintSystem::repairFailures(
21572152

21582153
case ConstraintLocator::TypeParameterRequirement:
21592154
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+
21602160
if (auto *fix = fixRequirementFailure(*this, lhs, rhs, anchor, path))
21612161
conversionsOrFixes.push_back(fix);
21622162
break;
@@ -3380,23 +3380,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
33803380

33813381
if (path.back().isTypeParameterRequirement() ||
33823382
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;
33933387
}
3394-
3395-
auto *fix = MissingConformance::forRequirement(
3396-
*this, type, protocol->getDeclaredType(),
3397-
getConstraintLocator(locator));
3398-
if (!recordFix(fix))
3399-
return SolutionKind::Solved;
34003388
}
34013389

34023390
// If this is an implicit Hashable conformance check generated for each
@@ -6545,8 +6533,10 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix) {
65456533
// Always useful, unless duplicate of exactly the same fix and location.
65466534
// This situation might happen when the same fix kind is applicable to
65476535
// 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);
65506540
} else {
65516541
// Only useful to record if no pre-existing fix in the subexpr tree.
65526542
llvm::SmallDenseSet<Expr *> fixExprs;

0 commit comments

Comments
 (0)