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-9760] Can't add @escaping to an argument of generic function having typealiased function type #52188

Closed
nikolaykasyanov opened this issue Jan 25, 2019 · 9 comments

Comments

@nikolaykasyanov
Copy link

@nikolaykasyanov nikolaykasyanov commented Jan 25, 2019

Previous ID SR-9760
Radar rdar://problem/47550733
Original Reporter @nikolaykasyanov
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 10.2 beta (10P82s)

Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)

Target: x86_64-apple-darwin18.2.0

ABI version: 0.6

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

md5: d7be05a7d980928bf2303b1dee8fe3ed

is duplicated by:

Issue Description:

This code snippet doesn't compile in Swift 5:

public enum Outcome {
    case A
    case B
}

public protocol Runner {
    typealias Completion = (Outcome) -> ()
    func run<D>(input: D, completion: @escaping Completion)
}
error: @escaping attribute only applies to function types
    func run<D>(input: D, completion: @escaping Completion)
                                      ~^~~~~~~~~~~~~~~~~~

It compiles if function isn't generic though.

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Jan 25, 2019

Thanks, this is definitely a regression. It works for non-generic protocol requirements, and generic functions inside non-protocols. Only generic functions in protocols are busted. I think I know why...

@belkadan
Copy link
Contributor

@belkadan belkadan commented Jan 25, 2019

@theblixguy, did your recent fix cover this?

@belkadan
Copy link
Contributor

@belkadan belkadan commented Jan 25, 2019

Oh, I didn't realize this was a regression at first. Thanks for the report, Nikolay!

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Jan 25, 2019

The problem is that protocol type aliases are resolved as DependentMemberType in the structural stage of type resolution. We need to ignore attributes in this stage instead of diagnosing them.

@theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Feb 1, 2019

Fixed on master and Swift 5.0 branch.

@nikolaykasyanov
Copy link
Author

@nikolaykasyanov nikolaykasyanov commented Feb 5, 2019

Thank you!

@nikolaykasyanov
Copy link
Author

@nikolaykasyanov nikolaykasyanov commented Feb 20, 2019

May I ask how long it usually takes for a fix to land in Xcode beta? Beta 3 doesn't have this fix.

@theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Feb 20, 2019

This should be available in the next beta or the final release (whichever comes next). 

@nikolaykasyanov
Copy link
Author

@nikolaykasyanov nikolaykasyanov commented Feb 21, 2019

@theblixguy thank you.

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

No branches or pull requests

4 participants