[ConstraintSystem] Minor refactor to avoid creating scopes we don't need.

This probably won't hit much, and shouldn't change behavior in any way
outside of statistics we generate about the number of scopes that get
opened.
This commit is contained in:
Mark Lacey
2018-08-29 18:32:48 -07:00
parent 1ec8b33efe
commit 026d41556d

View File

@@ -623,16 +623,15 @@ bool ConstraintSystem::tryTypeVariableBindings(
<< "\n";
}
// If we were able to solve this without considering
// default literals, don't bother looking at default literals.
if (anySolved && binding.DefaultedProtocol && !sawFirstLiteralConstraint)
break;
// Try to solve the system with typeVar := type
ConstraintSystem::SolverScope scope(*this);
if (binding.DefaultedProtocol) {
// If we were able to solve this without considering
// default literals, don't bother looking at default literals.
if (!sawFirstLiteralConstraint) {
sawFirstLiteralConstraint = true;
if (anySolved)
break;
}
sawFirstLiteralConstraint = true;
type = openUnboundGenericType(type, typeVar->getImpl().getLocator());
type = type->reconstituteSugar(/*recursive=*/false);
} else if (binding.BindingSource == ConstraintKind::ArgumentConversion &&