Skip to content

Commit 026d415

Browse files
committed
[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.
1 parent 1ec8b33 commit 026d415

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,16 +623,15 @@ bool ConstraintSystem::tryTypeVariableBindings(
623623
<< "\n";
624624
}
625625

626+
// If we were able to solve this without considering
627+
// default literals, don't bother looking at default literals.
628+
if (anySolved && binding.DefaultedProtocol && !sawFirstLiteralConstraint)
629+
break;
630+
626631
// Try to solve the system with typeVar := type
627632
ConstraintSystem::SolverScope scope(*this);
628633
if (binding.DefaultedProtocol) {
629-
// If we were able to solve this without considering
630-
// default literals, don't bother looking at default literals.
631-
if (!sawFirstLiteralConstraint) {
632-
sawFirstLiteralConstraint = true;
633-
if (anySolved)
634-
break;
635-
}
634+
sawFirstLiteralConstraint = true;
636635
type = openUnboundGenericType(type, typeVar->getImpl().getLocator());
637636
type = type->reconstituteSugar(/*recursive=*/false);
638637
} else if (binding.BindingSource == ConstraintKind::ArgumentConversion &&

0 commit comments

Comments
 (0)