Recursive protocol constraints

Hi all,

Just a heads-up that I’ve been working on the implementation of recursive protocol constraints <swift/GenericsManifesto.md at main · apple/swift · GitHub; in master. For reference, this will eventually lead to allowing, e.g.,

  protocol Sequence {
    associatedtype SubSequence: Sequence
  }

and similar, which will be a major simplification for the Swift standard library. There are a *lot* of places in the Swift compiler where we assume that we can enumerate the complete set of nested types from a type parameter, e.g., if S is a Sequence then we try to enumerate S.SubSequence, S.SubSequence.SubSequence, S.SubSequence.SubSequence.SubSequence, which will end badly.

To implement recursive protocol constraints, we need to find and eliminate all of these assumptions in the compiler. I’ve put up a gist here cataloging the ones I know about:

  Implementing Recursive Protocol Constraints · GitHub

The goal is to reduce this gist to nothing as we eliminate these assumptions. If you know of any other places that make such assumptions, please tell me!

  - Doug