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-8595] Protocol extension on protocol with subclass where restriction doesn't apply : class semantics #51111

Closed
zwaldowski opened this issue Aug 21, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@zwaldowski
Copy link

Previous ID SR-8595
Radar None
Original Reporter @zwaldowski
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode Version 10.0 beta 6 (10L232m), Apple Swift version 4.2 (swiftlang-1000.0.36 clang-1000.10.44)

(Also occurs in Swift 4.1.x)

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

md5: a35b960b5edfe17ce447790f7be32d57

duplicates:

  • SR-5581 Proper support for protocol 'where' clause with constraints on 'Self'

Issue Description:

Consider a protocol with a class constraint: protocol Fooable: class

I can add a protocol extension to Fooable with a property that has a setter, and use the setter on with reference semantics. let x = MyClass(); x.bar = "qux"

Now consider adding a where constraint to the protocol: protocol Fooable where Self: UIViewController.

I am warned that marking the protocol `: class`, is redundant ("Redundant constraint" 'Self': 'AnyObject"), however, if I remove it I can no longer use the setter above with reference semantics ("Cannot assign to property: 'vc' is a 'let' constant"). If I ignore the warning, the original code still works.

@zwaldowski
Copy link
Author

Additionally, you can't have a weak var despite the constraint. I imagine that's the same issue, but can file it separately if it seems not.

@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