# Unlock Existential Types for All Protocols

**URL:** <https://forums.swift.org/t/unlock-existential-types-for-all-protocols/40665>\
**Category:** Pitches\
**Tags:** associatedtype, protocol, existential\
**Created:** [September 26, 2020, 8:52pm UTC](https://forums.swift.org/t/unlock-existential-types-for-all-protocols/40665 "2020-09-26T20:52:15Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![anandabits](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anandabits/32/355_2.png) [@anandabits](https://forums.swift.org/u/anandabits)\
**Post date:** [November 7, 2020, 12:15am UTC](https://forums.swift.org/t/unlock-existential-types-for-all-protocols/40665/34 "2020-11-07T00:15:56Z")

</div>

I think we want path-dependent types here.

```swift

protocol P {
  associatedtype B: Class
  var b: B { get }
  func takesB(_: B)
}

func takesP(p1: P, p2: P) {
 let b1 = p1.b 
 let b2 = p2.b
 p1.takesB(b1) // ok
 p2.takesB(b1) // error: b1 may be of the wrong type
 p2.takesB(b2) // ok
 p1.takesB(b2) // error: b2 may be of the wrong type

}

```

---

_[View the full topic](https://forums.swift.org/t/unlock-existential-types-for-all-protocols/40665)._
