Skip to content

[5.3] [Function builders] Use one-way constraints for closure parameters. #32323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

DougGregor
Copy link
Member

Introduce one-way constraints for the parameters of closures to which a
function builder is being applied. This was an intended part of the
model when one-way constraints were introduced, but somehow got
missed. This should further break up large constraints systems for
faster solving, and most likely won't break much source code in
practice.

Fixes rdar://problem/64231116.

Introduce an experimental mode (behind the flag
`experimental-one-way-closure-params`) that places one-way
constraints between closure parameter types and references to those
parameters within the body of the closure. The intent here is to
break up constraint systems further, potentially improving type
checking performance and making way for larger closure bodies to be
supported.

This is a source-breaking change when the body of a single-expression
closure is used to determine the parameter types. One obvious example
is when there is no contextual type, e.g.,

    let _ = { $0 + 1 }

this type-checks today because `1` becomes `Int`, which matches the
`+` overload with the type `(Int, Int) -> Int`, determining the
parameter type `Int` for the closure. Such code would not type-check
with one-way constraints.

(cherry picked from commit 64f903f)
Introduce one-way constraints for the parameters of closures to which a
function builder is being applied. This was an intended part of the
model when one-way constraints were introduced, but somehow got
missed. This should further break up large constraints systems for
faster solving, and *most likely* won't break much source code in
practice.

Fixes rdar://problem/64231116.

(cherry picked from commit f60d17b)
@DougGregor DougGregor requested a review from a team as a code owner June 11, 2020 20:13
@DougGregor
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - fd29659

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - fd29659

@DougGregor
Copy link
Member Author

@swift-ci please test Linux

@DougGregor
Copy link
Member Author

@swift-ci please test macOS

@DougGregor DougGregor merged commit 3e13ca6 into swiftlang:release/5.3 Jun 12, 2020
@DougGregor DougGregor deleted the function-builder-one-way-params-5.3 branch June 12, 2020 21:56
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants