Is it possible to express this in swift without the use of Primary Associated Types?

No. More and more people will be hitting this, now that it's possible with them. We need a new way to refine and constrain these "anies". Link with a link.

If you're willing to move the any outwards, you can do this, but it's not equivalent:

protocol User {
  associatedtype Helper: ModuleName.Helper
  var helper: Helper { get }
  func getHelp() -> Helper.ValueType
}
struct SomeUser<Helper: ModuleName.Helper>: User
where Helper.ValueType == String {
let users: [any User]
2 Likes