Skip to content

Instantly share code, notes, and snippets.

@DougGregor
Created February 24, 2017 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougGregor/2523309bb1ec799f6c745995ba23a6d8 to your computer and use it in GitHub Desktop.
Save DougGregor/2523309bb1ec799f6c745995ba23a6d8 to your computer and use it in GitHub Desktop.
False recursion
protocol P {
associatedtype PType
}
public protocol Q {
associatedtype QType: R
}
public protocol R {
associatedtype RType
}
func f<T: P>(_: T) where T.PType.RType: Q, T.PType.RType.QType == T.PType {}
// We get this signature: <T where T : P, T.PType : R, T.PType == T.PType.RType.QType, T.PType.RType : Q>
// But we should get this signature: <T where T : P, T.PType == T.PType.RType.QType, T.PType.RType : Q>
// The “T.PType: R” requirement is redundant, but pops up when building the canonical generic environment due to the recursion-breaking code being wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment