[Constraint System] Allow initialized let/var declarations in function builders.

Introduce support for initialized let/var declarations within function
builder closures, e.g.,

    let (a, b) = c()

We generate constraints for the declarations as elsewhere, but the types of
the declared variables (a and b in this case) are bound to the type of the
pattern by one-way constraints, to describe the flow of type information
through the closure.

Implements rdar://problem/57330696.
This commit is contained in:
Doug Gregor
2020-02-12 09:53:50 -08:00
parent 7f9029071d
commit 2347829324
4 changed files with 211 additions and 2 deletions

View File

@@ -476,3 +476,18 @@ func testIfConditions(cond: Bool, c1: Bool, i1: Int, i2: Int) {
testIfConditions(cond: true, c1: true, i1: 1, i2: 1)
// CHECK: testIfConditions
// CHECK-SAME: hello
// Use a "let" declaration within a function builder.
tuplify(true) { c in
"testLetDeclarations"
let (a, b) = (c, c && true)
if a == b {
"hello"
b
}
a
}
// CHECK: testLetDeclarations"
// CHECK-SAME: hello
// CHECK-SAME: true