Skip to content

Commit 04952fd

Browse files
committed
[TypeChecker] Implement result builder transform via AST modification
The transform changes closure body into a multi-statement closure with all of the implicit result builder calls and type-checks it like a regular closure. There are a couple of result builder specific changes mentioned below, otherwise the logic to generate constraints and apply solutions is unchanged: - Placeholder variable: A variable declaration that doesn't have a type deduced and infers it from its first use. If such a variable has an initializer, it would be type-checked during solution application. - TypeJoinExpr - an implicit expression that refers to a "join" variable and a set of expressions that should all produce the same type that becomes a type of a "join" variable.
1 parent 7375dcd commit 04952fd

File tree

3 files changed

+1031
-34
lines changed

3 files changed

+1031
-34
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4824,6 +4824,16 @@ class ConstraintSystem {
48244824
LLVM_NODISCARD
48254825
bool generateConstraints(ClosureExpr *closure);
48264826

4827+
/// Generate constraints for the body of the given function.
4828+
///
4829+
/// \param fn The function or closure expression
4830+
/// \param body The body of the given function that should be
4831+
/// used for constraint generation.
4832+
///
4833+
/// \returns \c true if constraint generation failed, \c false otherwise
4834+
LLVM_NODISCARD
4835+
bool generateConstraints(AnyFunctionRef fn, BraceStmt *body);
4836+
48274837
/// Generate constraints for the given (unchecked) expression.
48284838
///
48294839
/// \returns a possibly-sanitized expression, or null if an error occurred.

0 commit comments

Comments
 (0)