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-2493] Escaping and Type-aliases don't work together #45098

Closed
swift-ci opened this issue Aug 26, 2016 · 2 comments
Closed

[SR-2493] Escaping and Type-aliases don't work together #45098

swift-ci opened this issue Aug 26, 2016 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2493
Radar None
Original Reporter chriseidhof (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: de270f0eb69ba2760e8b414045a431b4

duplicates:

Issue Description:

I created a typealias for a sort descriptor:

typealias SortDescriptor<A> = (A, A) -> Bool

Now, when I try to create function that takes a sort descriptor and inverts it, the parameter should be marked as escaping, however, the compiler doesn't detect that, and worse, disallows it:

func invert<A>(_ x: SortDescriptor<A>) -> SortDescriptor<A> {
return { l, r in !x(l, r)
}

If I define the same function without the typealias, all is well:

// Exact same function, but now it needs to be marked as escaping... (which is correct)
func invert2<A>(_ x: @escaping (A,A) -> Bool) -> (A,A) -> Bool {
return { l, r in !x(l, r)
}

I can, however, call the first function just fine:

let gte: SortDescriptor<Int> = invert(<)

@swift-ci
Copy link
Collaborator Author

Comment by Chris Eidhof (JIRA)

Sorry about the messed up code samples, I have no clue how to convince JIRA to display it preformatted... The triple braces somehow disappear

@swift-ci
Copy link
Collaborator Author

Comment by Chris Eidhof (JIRA)

Btw, the generics are not the issue here, it's the same when you have a non-generic typealias, e.g. (Int,Int) -> Bool.

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

No branches or pull requests

1 participant