Skip to content

Commit 609b3e5

Browse files
committed
[CSStep] Conjunction: Tranform all unbound outer variables into placeholders during ambiguity
Since conjunction is not going to continue current solver path after discovering an ambiguity, let's just mark all of the unbound outer variables as placeholders to produce a complete solution.
1 parent bc43ced commit 609b3e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Sema/CSStep.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,16 @@ StepResult ConjunctionStep::resume(bool prevFailed) {
960960
// element does contribute to the overall score.
961961
restoreOriginalScores();
962962

963+
// Transform all of the unbound outer variables into
964+
// placeholders since we are not going to solve for
965+
// each ambguous solution.
966+
for (auto *typeVar : CS.getTypeVariables()) {
967+
if (!typeVar->getImpl().hasRepresentativeOrFixed()) {
968+
CS.assignFixedType(
969+
typeVar, PlaceholderType::get(CS.getASTContext(), typeVar));
970+
}
971+
}
972+
963973
// Note that `worseThanBestSolution` isn't checked
964974
// here because `Solutions` were pre-filtered, and
965975
// outer score is the same for all of them.

0 commit comments

Comments
 (0)