on Thu Dec 22 2016, Mikhail Seriukov <swift-users-AT-swift.org> wrote:

> Hello community! I' wondering if somebody can explain this to me.
> Please take look at the snippet.
>
> protocol P {}
> struct X:P {}
>
> func foo<A:P>(_ x:A) {}
>
> func bar() {
>     //let x = X() // this compiles
>     let x = X() as P // this does not compile. Why?
>     foo(x)
> }

It's not a bug, exactly.  In Swift we have the bizarre situation that P
(when used as a type) doesn't conform to P (when used as a generic
constraint).  Doug can probably tell us if there's a good reason for
that or if it's just a temporary limitation.  Doug?

-- 
-Dave

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to