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-2201] posible @autoclosure regression; type inference #44808

Closed
swift-ci opened this issue Jul 28, 2016 · 3 comments
Closed

[SR-2201] posible @autoclosure regression; type inference #44808

swift-ci opened this issue Jul 28, 2016 · 3 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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 28, 2016

Previous ID SR-2201
Radar rdar://problem/27594604
Original Reporter aventurella (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift Ver. 3.0 (Jun 20, 2016)
x86_64-ubuntu-linux-gnu

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

md5: c849b311738fb0ec6e7a8f67591775d7

Issue Description:

With swift 2.1 and 2.2 the following compiles successfully:

// action 1
func action<Result>(name: String, @autoclosure(escaping) value: () -> Result){}

// action 2
func action<Result, A1, A2>(name: String, callback: (A1, A2) -> Result){}


action("doStuff"){
    (arg0: String, arg1: String) -> String in
    return "bar"
}

The compiler properly infers the proper action function to be invoked, in this case // action 2 which requires the callback (A1, A2) -> Result

Under Swift 3.0 however:

// action 1
func action<Result>(_ name: String, value: @autoclosure(escaping) () -> Result){}

// action 2
func action<Result, A1, A2>(_ name: String, callback: (A1, A2) -> Result){}


action("doStuff"){
    (arg0: String, arg1: String) -> String in
    return "bar"
}

The compiler seems to decide // action 1 is the proper function to invoke and compilation fails with the following error:

ambiguous use of 'action(_:value:)'

It seems to consider:

action("doStuff"){
    (arg0: String, arg1: String) -> String in
    return "bar"
}

to be:

action("doStuff", value: () -> ((String, String) -> String))
@belkadan
Copy link
Contributor

cc @rudkx

@Dante-Broggi
Copy link
Contributor

This seems fixed by the Xcode 9.4.1 toolchain. If so, it should be closed.

@Dante-Broggi
Copy link
Contributor

Resolving as the provided code compiles for me, and no one has responded since I asked.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants