Skip to content

Commit 1440300

Browse files
committed
[CSClosure] Conjunctions should reference result builder type variables
If builder type is not fully resolved, conjunction should reference its variables otherwise it would get disconnected from required contextual constraints.
1 parent 1d0d067 commit 1440300

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Sema/CSClosure.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ static void createConjunction(ConstraintSystem &cs,
254254
// reference a type variable representing closure type,
255255
// otherwise it would get disconnected from its contextual type.
256256
referencedVars.push_back(cs.getType(closure)->castTo<TypeVariableType>());
257+
258+
// If builder type is not yet fully resolved, conjunction should
259+
// reference its variables otherwise it would get disconnected from
260+
// required contextual constraints.
261+
if (auto builder = cs.getAppliedResultBuilderTransform(closure)) {
262+
SmallPtrSet<TypeVariableType *, 4> builderVars;
263+
builder->builderType->getTypeVariables(builderVars);
264+
referencedVars.append(builderVars.begin(), builderVars.end());
265+
}
266+
257267
// Body of the closure is always isolated from its context, only
258268
// its individual elements are allowed access to type information
259269
// from the outside e.g. parameters/result type.

0 commit comments

Comments
 (0)