Skip to content

Commit 81afffe

Browse files
[CSSimplify] Handle generic argument for unsatisfied generic requirement bind constraint in repairFailures
1 parent a907a15 commit 81afffe

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ ConstraintSystem::matchDeepEqualityTypes(Type type1, Type type2,
22292229

22302230
SmallVector<unsigned, 4> mismatches;
22312231
auto result = matchDeepTypeArguments(
2232-
*this, subflags, args1, args2, locator,
2232+
*this, subflags | TMF_ApplyingFix, args1, args2, locator,
22332233
[&mismatches](unsigned position) { mismatches.push_back(position); });
22342234

22352235
if (mismatches.empty())
@@ -4270,6 +4270,24 @@ bool ConstraintSystem::repairFailures(
42704270
break;
42714271
}
42724272

4273+
case ConstraintLocator::GenericArgument: {
4274+
// If any of the types is a hole, consider it fixed.
4275+
if (lhs->isHole() || rhs->isHole())
4276+
return true;
4277+
4278+
// Ignoring the generic argument because we may have a generic requirement
4279+
// failure e.g. `String bind T.Element`, so let's drop the generic argument
4280+
// path element and recurse in repairFailures to check and potentially
4281+
// record the requirement failure fix.
4282+
path.pop_back();
4283+
4284+
if (path.empty() || !path.back().is<LocatorPathElt::AnyRequirement>())
4285+
break;
4286+
4287+
return repairFailures(lhs, rhs, matchKind, conversionsOrFixes,
4288+
getConstraintLocator(anchor, path));
4289+
}
4290+
42734291
default:
42744292
break;
42754293
}

0 commit comments

Comments
 (0)