[CSBindings] Separate inference storage from final product usable by the solver

`PotentialBindings` lost most of its responsibilities,
and are no longer comparable. Their main purpose now
is binding and metadata tracking (introduction/retraction).

New `BindingSet` type is something that represents a set
of bindings at the current step of the solver.
This commit is contained in:
Pavel Yaskevich
2021-02-09 20:59:30 -08:00
parent 9372215012
commit df7af0078f
8 changed files with 433 additions and 357 deletions

View File

@@ -5361,9 +5361,10 @@ bool ConstraintSystem::isReadOnlyKeyPathComponent(
return false;
}
TypeVarBindingProducer::TypeVarBindingProducer(PotentialBindings &bindings)
: BindingProducer(bindings.CS, bindings.TypeVar->getImpl().getLocator()),
TypeVar(bindings.TypeVar), CanBeNil(bindings.canBeNil()) {
TypeVarBindingProducer::TypeVarBindingProducer(BindingSet &bindings)
: BindingProducer(bindings.getConstraintSystem(),
bindings.getTypeVariable()->getImpl().getLocator()),
TypeVar(bindings.getTypeVariable()), CanBeNil(bindings.canBeNil()) {
if (bindings.isDirectHole()) {
auto *locator = getLocator();
// If this type variable is associated with a code completion token
@@ -5371,8 +5372,9 @@ TypeVarBindingProducer::TypeVarBindingProducer(PotentialBindings &bindings)
// to point to a code completion token to avoid attempting to "fix"
// this problem since its rooted in the fact that constraint system
// is under-constrained.
if (bindings.AssociatedCodeCompletionToken) {
locator = CS.getConstraintLocator(bindings.AssociatedCodeCompletionToken);
if (bindings.getAssociatedCodeCompletionToken()) {
locator =
CS.getConstraintLocator(bindings.getAssociatedCodeCompletionToken());
}
Bindings.push_back(Binding::forHole(TypeVar, locator));