Skip to content

[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

Merged
merged 1 commit into from
Sep 13, 2018
Merged

[ConstraintSystem] Infer empty closures as returning () more eagerly. #19282

merged 1 commit into from
Sep 13, 2018

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Sep 12, 2018

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

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
@rudkx
Copy link
Contributor Author

rudkx commented Sep 12, 2018

@swift-ci Please smoke test

@rudkx rudkx requested a review from xedin September 12, 2018 20:35
@rudkx
Copy link
Contributor Author

rudkx commented Sep 12, 2018

@swift-ci Please test source compatibility

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.

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 = { [] }
Copy link
Contributor

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?

Copy link
Contributor Author

@rudkx rudkx Sep 12, 2018

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.

Copy link
Contributor

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

@rudkx
Copy link
Contributor Author

rudkx commented Sep 12, 2018

@swift-ci Please smoke test OS X platform

@rudkx
Copy link
Contributor Author

rudkx commented Sep 12, 2018

@swift-ci Please clean smoke test OS X platform

@rudkx rudkx merged commit 64fe398 into swiftlang:master Sep 13, 2018
@rudkx rudkx deleted the rdar42337247 branch September 13, 2018 04:16
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.

3 participants