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-8154] Inconsistent treating of AnyObject as a protocol #50686

Open
hamishknight opened this issue Jun 29, 2018 · 3 comments
Open

[SR-8154] Inconsistent treating of AnyObject as a protocol #50686

hamishknight opened this issue Jun 29, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself standard library Area: Standard library umbrella

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-8154
Radar None
Original Reporter @hamishknight
Type Bug
Environment

Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0

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

md5: 2cc307df0845ba702863f6b6f8c90bc7

Issue Description:

The documentation for AnyObject currently describes it as:

The protocol to which all classes implicitly conform.

However, technically speaking, AnyObject is no longer a protocol. This fact can be revealed to the user through the invalid inheritance diagnostic:

class C : AnyObject {} // error: Inheritance from non-protocol, non-class type 'AnyObject'

Either the compiler should make AnyObject appear like a protocol to users, or the documentation should be changed to not state that it's a protocol.

@beccadax
Copy link
Contributor

Curiously, “class C: Any {}” is silently permitted without any complaint. It might make sense to do the same for AnyObject.

@hamishknight
Copy link
Collaborator Author

Personally, I agree – I think that class C : AnyObject should just be a warning along with class C : Any (I'm currently working on implementing the latter over at #17425

@belkadan
Copy link
Contributor

belkadan commented Jul 2, 2018

cc @natecook1000

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants