Sequence is not a protocol?

Since LazySequenceProtocol doesn't have a primary associated type, instead of any LazySequenceProtocol<UInt32>, I put any LazySequenceProtocol & Sequence<UInt32>. To my surprise, the compiler complained:

error: non-protocol, non-class type 'Sequence<UInt32>' cannot be used within a protocol-constrained type

Since when is Sequence not a protocol? Right click -> Go to definition on the word Sequence in that type definition takes me to this line of an autogenerated .swiftinterface:

public protocol Sequence<Element> {

The diagnostic is misleading but it fires because you have a constrained protocol type as a member of a protocol composition, something that is not supported yet but hopefully one day when I finish this PR: Allow existential parameterized compositions: `any P<A> & Q` by slavapestov · Pull Request #76705 · swiftlang/swift · GitHub

7 Likes