# Class-only protocols, class vs AnyObject?

**URL:** <https://forums.swift.org/t/class-only-protocols-class-vs-anyobject/11507>\
**Category:** Using Swift\
**Created:** [March 30, 2018, 7:41am UTC](https://forums.swift.org/t/class-only-protocols-class-vs-anyobject/11507 "2018-03-30T07:41:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [March 30, 2018, 9:06am UTC](https://forums.swift.org/t/class-only-protocols-class-vs-anyobject/11507/4 "2018-03-30T09:06:16Z")

</div>

The StackOverflow answer is out of date as of Swift 4. `protocol P : class {}` and `protocol P : AnyObject {}` parse identically and there's no semantic difference between them. We should add a warning to deprecate the former at some point.

---

_[View the full topic](https://forums.swift.org/t/class-only-protocols-class-vs-anyobject/11507)._
