Skip to content

Commit a9d850d

Browse files
committed
---
yaml --- r: 319453 b: refs/heads/master-rebranch c: 3b0ee99 h: refs/heads/master i: 319451: 5369cca
1 parent 289a446 commit a9d850d

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: 8b3709e80b6af5f8d225d50376e7f2eb41a15c4e
1460+
refs/heads/master-rebranch: 3b0ee9990d67a1b04ce63a2e596df6326aa8eb4e

branches/master-rebranch/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)