Skip to content

Commit 4c98b31

Browse files
committed
[Constraint solver] Apply solution to the system before builder transform.
This makes sure we can find information in the constraint system during application. Fixes rdar://problem/59239224
1 parent 3508dfb commit 4c98b31

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,9 @@ Optional<BraceStmt *> TypeChecker::applyFunctionBuilderBodyTransform(
11011101
// The system was salvaged; continue on as if nothing happened.
11021102
}
11031103

1104+
// FIXME: Shouldn't need to do this.
1105+
cs.applySolution(solutions.front());
1106+
11041107
// Apply the solution to the function body.
11051108
if (auto result = cs.applySolution(
11061109
solutions.front(),

test/Constraints/function_builder_diags.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,17 @@ func checkImplicitSelfInClosure() {
327327
}
328328
}
329329
}
330+
331+
// rdar://problem/59239224 - crash because some nodes don't have type
332+
// information during solution application.
333+
struct X<T> {
334+
init(_: T) { }
335+
}
336+
337+
@TupleBuilder func foo(cond: Bool) -> some Any {
338+
if cond {
339+
tuplify(cond) { x in
340+
X(x)
341+
}
342+
}
343+
}

0 commit comments

Comments
 (0)