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-2306] Should a noescape closure be a subtype of an escaping closure? #44913

Closed
swift-ci opened this issue Aug 9, 2016 · 1 comment
Closed
Assignees
Labels
compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement protocol Feature → type declarations: Protocol declarations type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 9, 2016

Previous ID SR-2306
Radar None
Original Reporter chriseidhof (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

swift-DEVELOPMENT-SNAPSHOT-2016-08-04

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

md5: 7d9cc7cc1833db1813b64ec3c29ad96d

duplicates:

  • SR-522 Protocol funcs cannot have covariant returns

Issue Description:

If I define a protocol like this:

protocol Escaping { func test(closure: @escaping () -> ()) }

I cannot make a type conform which has a more restrictive noescape closure:

class Test: Escaping {  
  func test(closure: () -> ()) {
  }  
}

Seems like it should work. I initially got a bit confused, but noescape is not so much an attribute of the closure, it's more an effect of the method.

Seems like the code above should be possible. Not sure what the implications are.

@belkadan
Copy link
Contributor

belkadan commented Aug 9, 2016

The subtyping relation is there, but protocol requirements don't currently allow subtyping.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue feature A feature request or implementation conformances Feature → protocol: protocol conformances protocol Feature → type declarations: Protocol declarations improvement and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. labels Jan 27, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances duplicate Resolution: Duplicates another issue feature A feature request or implementation improvement protocol Feature → type declarations: Protocol declarations type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants