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
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.0

Comments

@nikolaykasyanov
Copy link

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

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

@theblixguy, did your recent fix cover this?

@belkadan
Copy link
Contributor

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

@slavapestov
Copy link
Member

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.

@nikolaykasyanov
Copy link
Author

Thank you!

@nikolaykasyanov
Copy link
Author

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

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

@nikolaykasyanov
Copy link
Author

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.0
Projects
None yet
Development

No branches or pull requests

5 participants