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-2423] Ambiguous use of method in unambiguous case #45028

Closed
swift-ci opened this issue Aug 19, 2016 · 7 comments
Closed

[SR-2423] Ambiguous use of method in unambiguous case #45028

swift-ci opened this issue Aug 19, 2016 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2423
Radar None
Original Reporter mpdifran (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift 2.3
Xcode 7.3

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee @xedin
Priority Medium

md5: d36aff4696e4f55f5c14420fad211c7c

relates to:

  • SR-5780 Swift 4 compiler reports ambiguity for method invocation

Issue Description:

  1. When a program has two methods that have the same signature (a single closure parameter), but the closures have a different number of arguments, the compiler still can't infer which method is intended when calling one of the methods.

A workaround does exist by specifying the type of the closure parameters, but that shouldn't be necessary.

See attached playground for a specific example.

@belkadan
Copy link
Contributor

From the playground:

func performAction(closure: (Int) -> Void) {
    closure(7)
}

func performAction(closure: (String, Int) -> Void) {
    closure("Key", 7)
}

// This should not throw a compiler error because the use is not ambiguous.
performAction { value in
    print(value)
}

// Workaround
performAction { (value: Int) in
    print(value)
}

Seems like we're just not done removing the code that allowed a single closure argument to match a tuple.

@belkadan
Copy link
Contributor

(it does still reproduce in Swift 3)

@belkadan
Copy link
Contributor

@DougGregor, are there dups of this?

@DougGregor
Copy link
Member

I don't know any off-hand; it's closely related to SE-0110, an implementation for which recently landed in master.

@DougGregor
Copy link
Member

... but which didn't fix it.

@xedin
Copy link
Member

xedin commented Nov 17, 2017

Looks like this problem is fixed in Swift 4, mpdifran (JIRA User) Can you please verify and resolve this issue?

@swift-ci
Copy link
Collaborator Author

Comment by Mark DiFranco (JIRA)

Yup, tested with the attached playground. There's no longer an error.

@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
Projects
None yet
Development

No branches or pull requests

4 participants