Constrained PAT subprotocol

Hello folks,
I want to understand if the following is intended, is an "incomplete feature" or if I am missing something (probably):

protocol BaseProto {
  associatedtype AssociatedType
}

// This *is expected*
// Error: Protocol 'BaseProto' can only be used as a generic
//   constraint because reasons
func test1(base: BaseProto) { ... }

protocol SubProto: BaseProto where AssociatedType == Int {
  // nothing added here
}

// This I *did not expect*
// Error: Protocol 'SubProto' can only be used as a generic
//   constraint because the same reasons
func test2(sub: SubProto) { ... }

Why SubProto, even if it fixes the type of AssociatedType, is still considered a PAT? Isn't this the same as declaring typealias AssociatedType = Int? :thinking:

1 Like
Terms of Service

Privacy Policy

Cookie Policy