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-7563] Generic class with AnyObject constraint won't except protocol that also has AnyObject constraint #50105

swift-ci opened this issue Apr 28, 2018 · 1 comment


Copy link

@swift-ci swift-ci commented Apr 28, 2018

Previous ID SR-7563
Radar None
Original Reporter kdawgwilk (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download


Xcode 9.3

macOS 10.13.4

Swift 4.1

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

md5: a05c1124d8c541ab8b4de70686ccfd12


  • SR-55 non-@objc protocol existentials do not conform to their own protocol type

Issue Description:

This feels like it should be possible but maybe I am just being naive?

import Foundation

class A<ClassDelegate: AnyObject> {
    weak var delegate: ClassDelegate?

protocol P: AnyObject {}

class B: A<P> {}

![](Screen Shot 2018-04-28 at 12.13.34 PM.png)

Copy link

@belkadan belkadan commented May 1, 2018

This is correct behavior: a protocol value carries with it both the underlying class reference and the information about how the class conforms to the protocol (the witness table). This isn't compatible with the representation of AnyObject.

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

No branches or pull requests

2 participants