[swift-users] Weird protocol behaviour.

Mikhail Seriukov zloisop at gmail.com
Thu Dec 22 10:05:18 CST 2016

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?

I expect the both cases to work though. But only first works? And I do not
understand why.
My coworkers said that it is a compiler bug, but I'm not shure it is.
Thanks for the help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161222/062f78b5/attachment.html>

More information about the swift-users mailing list