Skip to content

Allow initialized let/var declarations in function builders.#29786

Merged
DougGregor merged 3 commits intoswiftlang:masterfrom
DougGregor:function-builders-let-decls
Feb 13, 2020
Merged

Allow initialized let/var declarations in function builders.#29786
DougGregor merged 3 commits intoswiftlang:masterfrom
DougGregor:function-builders-let-decls

Conversation

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Feb 12, 2020

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.

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.

…rget.

Pull out the core operation of rewriting a given SolutionApplicationTarget
into into a method on the ExprWalker that does the overall rewrite, so it
can be called multiple times within application.
When applying a function builder to a closure to produce the final,
type-checked closure, use the new rewriteTarget() so it’s performed on
a per-target basis. Use this to eliminate some duplicating in the handling
of return types.
…n 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.
@DougGregor DougGregor force-pushed the function-builders-let-decls branch from 568ff52 to 2347829 Compare February 13, 2020 01:55
@DougGregor
Copy link
Member Author

The first two commits are from #29801; only the third commit is needed here.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor DougGregor requested a review from xedin February 13, 2020 01:56
@DougGregor DougGregor marked this pull request as ready for review February 13, 2020 04:24
@DougGregor DougGregor changed the title [WIP] Allow initialized let/var declarations in function builders. Allow initialized let/var declarations in function builders. Feb 13, 2020
@DougGregor DougGregor merged commit 08315b1 into swiftlang:master Feb 13, 2020
@DougGregor DougGregor deleted the function-builders-let-decls branch February 13, 2020 04:50
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants