[CSBindings] Check literal coverage as new bindings/requirements are discovered

One more step towards incrementality of binding inference. Instead of
trying to determine literal protocol coverage during finalization
of the bindings, let's do that as soon as new bindings and/or literal
protocol requirements are discovered.
This commit is contained in:
Pavel Yaskevich
2020-12-24 11:13:44 -08:00
parent 41623abe49
commit 731810e184
3 changed files with 166 additions and 113 deletions

View File

@@ -5330,11 +5330,7 @@ bool ConstraintSystem::isReadOnlyKeyPathComponent(
TypeVarBindingProducer::TypeVarBindingProducer(
ConstraintSystem::PotentialBindings &bindings)
: BindingProducer(bindings.CS, bindings.TypeVar->getImpl().getLocator()),
TypeVar(bindings.TypeVar),
CanBeNil(llvm::any_of(bindings.Literals, [](const auto &literal) {
return literal.first->isSpecificProtocol(
KnownProtocolKind::ExpressibleByNilLiteral);
})) {
TypeVar(bindings.TypeVar), CanBeNil(bindings.canBeNil()) {
if (bindings.isDirectHole()) {
auto *locator = getLocator();
// If this type variable is associated with a code completion token