# Generic \`where\` fails for protocol types

**URL:** <https://forums.swift.org/t/generic-where-fails-for-protocol-types/63729>\
**Category:** Using Swift\
**Created:** [March 15, 2023, 3:13pm UTC](https://forums.swift.org/t/generic-where-fails-for-protocol-types/63729 "2023-03-15T15:13:23Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![lhunath](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lhunath/32/18794_2.png) [@lhunath](https://forums.swift.org/u/lhunath)\
**Post date:** [March 15, 2023, 3:13pm UTC](https://forums.swift.org/t/generic-where-fails-for-protocol-types/63729/1 "2023-03-15T15:13:23Z")

</div>

Swift seems unable to recognize a protocol type that conforms to another protocol type in a `where` clause.

Let's assume `protocol A` and `protocol B: A`; in this case `where B: A` fails. The same is true for the `is` operator.

This does not match user expectations and breaks some generics use cases. Example:

```swift
protocol A {}
protocol B: A {}
class C: B {}

func f<P>(_ p: P.Type, _ i: @autoclosure () -> P) {
    print("1")
}
func f<P>(_ p: P.Type, _ i: @autoclosure () -> P) where P: A {
    print("2")
}

f(B.self, C())
f(C.self, C())

```

I expect to see:

```swift
2
2

```

but instead, I see:

```swift
1
2

```

Does anyone have insight? Should I file a bug?

---

_[View the full topic](https://forums.swift.org/t/generic-where-fails-for-protocol-types/63729)._
