Type can only be used as a generic constraint even if associated type specified

Hi everyone,

I have the following code:

protocol A: Identifiable where ID==String {
// something here
}

class B {
var listOfA: [A]
}

Now the compiler gives error "can only be used as a generic constraint...". I understand this error, I mean I understand why the associated type ID can normally be different things for different implementations. But my question is: what is wrong in this particular case where we put the constraint ID == String? Why do we still have ambiguity in this case?

This has come up in the past, though I'm not sure if there's been much motion since the last post in that thread. @anthonylatsis, has there been further progress since the linked post?

1 Like

This will be proposed alongside SE-NNNN (we're almost ready to schedule the review).

3 Likes
Terms of Service

Privacy Policy

Cookie Policy