-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Experiment] One-way closure parameters #32215
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
@swift-ci please test source compatibility |
@DougGregor This failure is actually want is preventing my PR for |
Ah, tricky, tricky. Maybe we can (temporarily?) patch things up in SwiftDriver and SwiftPM to at least get a complete set of results, but it might be that one-way constraints cannot be used for single-expression closures. Or maybe for closures involving |
Yeah, if I remember correctly there were some compatibility suite failures with that as well. |
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.
49f3ab3
to
6b2dfad
Compare
6b2dfad
to
64f903f
Compare
Here's just the experimental flag, which includes the semantics we're going to need elsewhere. The "one way by default" experiment is over at #32222. |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci smoke test Linux |
Introduce an experimental mode (behind the flag
experimental-one-way-closure-params
) that places one-wayconstraints 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.,
this type-checks today because
1
becomesInt
, which matches the+
overload with the type(Int, Int) -> Int
, determining theparameter type
Int
for the closure. Such code would not type-checkwith one-way constraints.