Skip to content

Commit 1d9d204

Browse files
authored
Merge pull request #19063 from rudkx/a-few-less-scopes
[ConstraintSystem] Minor refactor to avoid creating scopes we don't n…
2 parents 48b7758 + 026d415 commit 1d9d204

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)