-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Infer empty closures as returning () more eagerly. #19282
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
We previously allowed these closures to default to (), but be inferred as other types as well, which means that we will find some expressions to be ambiguous because we end up finding multiple viable solutions where there is really only one reasonable solution. Fixes: rdar://problem/42337247
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! It definitely make sense to disambiguate the case with no expressions in the body of the closure.
@@ -154,7 +154,7 @@ class Test: NSObject { | |||
// CHECK: return [[RESULT]] | |||
|
|||
func clearDraggingItemImageComponentsProvider(_ x: NSDraggingItem) { | |||
x.imageComponentsProvider = {} | |||
x.imageComponentsProvider = { [] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a language change? Does it need to be guarded under -swift-version 5
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote the commit message just before pushing and accidentally deleted the sentence about the updated test cases being ones where data flow diagnostics emit an error currently.
It looks like after reworking the approach to fixing this I also left in at least one test update that isn’t strictly necessary with my changes but isn’t harmful either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't comment about it because I tried second modified test-case and it did produce an error without return 0
@swift-ci Please smoke test OS X platform |
@swift-ci Please clean smoke test OS X platform |
We previously allowed these closures to default to (), but be inferred
as other types as well, which means that we will find some expressions
to be ambiguous because we end up finding multiple viable solutions
where there is really only one reasonable solution.
Fixes: rdar://problem/42337247