Protocols are in better shape than concrete types now

Swift 5.7, the good, and...

// πŸŽ‰ Sooo good
extension Collection<String> { ... }

// 😭 Constrained extension must be declared on the unspecialized
// generic type 'Set' with constraints specified by a 'where' clause
extension Set<String> { ... }

For concrete types, the code that is accepted by the compiler is much less nice than the constrained protocol extension:

extension Set where Element == String { }

The lack of symmetry is really not beautiful. Developers also need to extend concrete generic types, not only protocols!

Is it something that is already planned? Or is it worth being filed as an enhancement request? Or would we need a proper evolution process?

https://forums.swift.org/t/pitch-extensions-on-bound-generic-types/

1 Like

Thank you! Apologies for the noise!