Skip to content
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

[SR-2812] Swift 3's overload resolution for closure arguments differs from Swift 2.x #45416

Closed
swift-ci opened this issue Oct 1, 2016 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 3.0

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 1, 2016

Previous ID SR-2812
Radar rdar://problem/35142121
Original Reporter snw (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift 4.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.0Regression
Assignee @xedin
Priority Medium

md5: 0849862e65da6ea9ebd4d576385c291d

Issue Description:

Function overload resolution behavior has changed in Swift 3 regarding picking the most narrow available overload for closure types. For example:

func f<T>(_ a: T) {
    print("Wide")
}

func f(_ a: (Int)->(Int)) {
    print("Narrow")
}

f({(a: Int) -> Int in return a + 1})

In Swift 2.x this prints "Narrow", but in Swift 3.0 it prints "Wide." If the argument were of type Int instead of an (Int) -> Int (and the function was called with an appropriate argument) it would print "Narrow" under both Swift 3 and Swift 2.x. Not sure if this change was intentional or not but I didn't see it mentioned in any swift-evolution proposal or otherwise documented.

@belkadan
Copy link
Contributor

belkadan commented Oct 3, 2016

@DougGregor, would you say this is expected?

@swift-ci
Copy link
Collaborator Author

Comment by Andrew Snow (JIRA)

This behavior remains in Swift 4.0

@belkadan
Copy link
Contributor

"Still broken in 4.0" is distinct from "a regression in 4.0". The regression labels mark when an issue was first introduced.

@belkadan
Copy link
Contributor

cc @xedin

@xedin
Copy link
Member

xedin commented Oct 24, 2017

@swift-ci create

@xedin
Copy link
Member

xedin commented Nov 1, 2017

Changes merged as #12593, snw (JIRA User) Please verify and resolve using next available nightly build.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 3.0
Projects
None yet
Development

No branches or pull requests

4 participants