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-7372] Reject conditional conformances of @objc protocols #49920

Closed
belkadan opened this issue Apr 6, 2018 · 5 comments
Closed

[SR-7372] Reject conditional conformances of @objc protocols #49920

belkadan opened this issue Apr 6, 2018 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@belkadan
Copy link
Contributor

belkadan commented Apr 6, 2018

Previous ID SR-7372
Radar None
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9.3(9E145), Swift 4.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 51a5a295488c87a93365265b968b13ec

cloned from:

  • SR-7370 Generic class conforming to @objc protocol fails assertion: "extended objc class doesn't have constant metadata?"

Issue Description:

import Foundation

public class FooClass<T> {

}

@objc protocol BarProtocol {

}

extension FooClass: BarProtocol where T: BarProtocol {
    
}

The code above crashes because of SR-7370, but it probably shouldn't be accepted in the first place. We'd have to check all the conditions up front when doing a new instantiation otherwise.

@belkadan
Copy link
Contributor Author

belkadan commented Apr 6, 2018

@huonw, @jckarter, what do you think?

@jckarter
Copy link
Member

jckarter commented Apr 6, 2018

I guess this is theoretically implementable, since we could register the conformance with the ObjC runtime when we form the class object conditional on the constraints succeeding, but I'm not sure it's worth it. We should reject it now since it isn't implemented at all, I agree.

@huonw
Copy link
Mannequin

huonw mannequin commented Apr 6, 2018

Oops![]( We'd realised this doesn't work for {{@objc}} classes and disallowed it, but {{@objc}} protocols didn't cross my mind. Sounds good to me)

@huonw
Copy link
Mannequin

huonw mannequin commented Apr 9, 2018

#15822

@huonw
Copy link
Mannequin

huonw mannequin commented Apr 10, 2018

Merged that PR.

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

No branches or pull requests

2 participants