Protocol as return type

In swift language guide-"Opaque Types"-"Differences Between Opaque Types and Protocol Types", it said:

"Another problem with this approach is that the shape transformations don’t nest. The result of flipping a triangle is a value of type Shape, and the protoFlip(:) function takes an argument of some type that conforms to the Shape protocol. However, a value of a protocol type doesn’t conform to that protocol; the value returned by protoFlip(:) doesn’t conform to Shape. This means code like protoFlip(protoFlip(smallTriange)) that applies multiple transformations is invalid because the flipped shape isn’t a valid argument to protoFlip(:)"

I can't understand why it said"a value of a protocol type doesn’t conform to that protocol; the value returned by protoFlip(
:) doesn’t conform to Shape". The return value must conform to Shape. It's a fundamental requirement by function signature, isn't it?
Answered by OOPer in 673914022

You mean, just treat it as a rule? 

YES. It is not a description specific to this case, it is a general rule of protocol in Swift.
The only exception I know is the protocol Error, which conforms to Error.

The return value must conform to Shape. It's a fundamental requirement by function signature, isn't it? 

NO.

The return value must conform to Shape. It's a fundamental requirement by function signature, isn't it? 
NO.

The reason is?

The reason is?

Already written.

a value of a protocol type doesn’t conform to that protocol;

You mean, just treat it as a rule?
Accepted Answer

You mean, just treat it as a rule? 

YES. It is not a description specific to this case, it is a general rule of protocol in Swift.
The only exception I know is the protocol Error, which conforms to Error.
Thanks a lot for your explanation.
In fact, many developers are struggling with this characteristics of Swift protocols.

If you have some interest in the future of Swift, forums.swift.org may be a good place to learn and discuss.
Thanks again for your suggestion.
Protocol as return type
 
 
Q