Are primary associated types supposed to be transitive?

Have a function that returns "some Sequence<MyElement>." The sequence type is also a lazy sequence, but "some LazySequenceProtocol<MyElement>" doesn't work. So:

  • Transitivity is supposed to work, but there's a (major) problem with the compiler.
  • Transitivity isn't supported, and the Swift team forgot to tag a primary associative type for LazySequenceProtocol.
  • The Swift team deliberately doesn't want to give LazySequenceProtocol a primary type.

I can see transitivity not (initially?) being supported a valid decision, so I'm guessing the answer is #2. Unless someone can supply a reason why it's actually #3.

1 Like

I don't know the answer. I've just used composition to get around it so far.

some Sequence<MyElement> & LazySequenceProtocol
2 Likes

It's actually #3, because there was doubt about the right primary associated type, which would notably not have been Element.

6 Likes