Skip to content

Commit fda7530

Browse files
committed
[CSBindings] Relax early conjunction solving rule related to outer declarations
Instead of checking that there are no references to external declarations, let's check that all of such declarations have their types resolved.
1 parent 5bb9d75 commit fda7530

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,18 +1111,18 @@ bool BindingSet::favoredOverConjunction(Constraint *conjunction) const {
11111111
}))
11121112
return true;
11131113

1114-
// If conjunction references a single type variable (closure itself)
1115-
// it means that the builder is either not generic or has all of its
1116-
// generic parameter specified explicitly, and there are no references
1117-
// to declarations from outer context. Such conjunctions don't have to
1118-
// be delayed.
1119-
if (conjunction->getTypeVariables().size() == 1) {
1120-
assert(
1121-
conjunction->getTypeVariables()[0]->isEqual(CS.getType(closure)));
1122-
return false;
1123-
}
1124-
1125-
return true;
1114+
// Check whether conjunction has any unresolved type variables
1115+
// besides the variable that represents the closure.
1116+
//
1117+
// Conjunction could refer to declarations from outer context
1118+
// (i.e. a variable declared in the outer closure) or generic
1119+
// parameters of the builder type), if any of such references
1120+
// are not yet inferred the conjunction has to be delayed.
1121+
auto *closureType = CS.getType(closure)->castTo<TypeVariableType>();
1122+
return llvm::any_of(
1123+
conjunction->getTypeVariables(), [&](TypeVariableType *typeVar) {
1124+
return !(typeVar == closureType || CS.getFixedType(typeVar));
1125+
});
11261126
}
11271127
}
11281128

0 commit comments

Comments
 (0)