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-317] rethrows does not recognize an optional throwing closure as a valid candidate #42939

Closed
swift-ci opened this issue Dec 19, 2015 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-317
Radar None
Original Reporter russ (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift 2, Xcode 7.2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, StarterBug
Assignee @ahoppen
Priority Medium

md5: b86bddc1ab015762c18378edabebf811

Issue Description:

In this example, the compiler does not consider the optional closure as a valid satisfaction of the rethrows requirement. I believe it should.

extension Optional {
    func apply<U>(f: ((Wrapped) throws -> U)?) rethrows -> U? {
        return try f.flatMap(self.map)
    }
}
@ahoppen
Copy link
Contributor

ahoppen commented Mar 11, 2016

I have fixed the issue that rethrows does not work properly with optional function parameter (#1642
However when testing on your example, I hit a different issue that was just shadowed by this bug, namely that the following code does not compile even though there are no throwing/rethrowing declarations:

extension Optional {
  func apply<U>(f: ((Wrapped) -> U)?) -> U? {
    return f.flatMap(self.map) // Error: Call can throw, but it is not marked with 'try' and the error is not handled
  }
}

Although I didn’t investigate further, this seems like a different bug to me. I would suggest opening a new issue for it.

@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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants