Skip to content

[4.1][CSSolver] Increment score when performing certain function conversions #14464

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
Feb 8, 2018

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Feb 7, 2018

Explanation: Increase solution score when performing function conversions where only
one side has @autoclosure. That is going to help pick the best overload
when only difference lays in presence of such attribute.

e.g.

func foo(_: @autoclosure () -> Int) {}
func foo(_: () -> Int) {}

If the argument is itself @autoclosure it's preferable to use overload
with @autoclosure attribute, otherwise () -> Int should be used.
Scope of Issue: Affects matching of the arguments to parameters marked with @autoclosure attributes.
Origination: Caused by the attempt to fix nil coalescing operator to support optional closures.
Risk: Low risk; Fixes a bug in constraint solver.
Reviewed By: @rudkx
Testing: Compiler regression tests
Radar / SR: rdar://problem/37160679

Resolves: rdar://problem/37160679
(cherry picked from commit 8316353)

@xedin xedin requested a review from rudkx February 7, 2018 19:11
@xedin
Copy link
Contributor Author

xedin commented Feb 7, 2018

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Feb 7, 2018

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

swift-ci commented Feb 7, 2018

Build failed
Swift Test Linux Platform
Git Sha - ff42397c8a7c5b6447de4f30b5ada6649d031c1b

@swift-ci
Copy link
Contributor

swift-ci commented Feb 7, 2018

Build failed
Swift Test OS X Platform
Git Sha - ff42397c8a7c5b6447de4f30b5ada6649d031c1b

Increase solution score when performing function conversions where only
one side has `@autoclosure`. That is going to help pick the best overload
when only difference lays in presence of such attribute.

e.g.

```swift
func foo(_: @autoclosure () -> Int) {}
func foo(_: () -> Int) {}
```

If the argument is itself `@autoclosure` it's preferable to use overload
with `@autoclosure` attribute, otherwise `() -> Int` should be used.

Resolves: rdar://problem/37160679
(cherry picked from commit 8316353)
@xedin xedin force-pushed the rdar-37160679-4.1 branch from ff42397 to 8d6f1f2 Compare February 7, 2018 22:50
@xedin
Copy link
Contributor Author

xedin commented Feb 7, 2018

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Feb 7, 2018

Build failed
Swift Test OS X Platform
Git Sha - ff42397c8a7c5b6447de4f30b5ada6649d031c1b

@swift-ci
Copy link
Contributor

swift-ci commented Feb 7, 2018

Build failed
Swift Test Linux Platform
Git Sha - ff42397c8a7c5b6447de4f30b5ada6649d031c1b

@xedin
Copy link
Contributor Author

xedin commented Feb 7, 2018

@swift-ci please test source compatibility

Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@xedin
Copy link
Contributor Author

xedin commented Feb 8, 2018

@swift-ci please nominate

@AnnaZaks AnnaZaks merged commit 6d91274 into swiftlang:swift-4.1-branch Feb 8, 2018
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.

4 participants