Making associated type concrete in struct still yields "can only be used as a generic constraint" error

I'm going to ask this question again, because I still don't think it makes any sense.

Take the following example.

protocol MyItem: Identifiable {
    var id: Int { get }
}

let items: [MyItem] = [] // can only be used as a generic constraint...

A solution is available, though, as below.

protocol MyItemProtocol {
    var id: Int { get }
}

protocol MyItem: MyItemProtocol, Identifiable { }

let myItems: [MyItemProtocol] = []

The above works, but it seems arbitrary unnecessary to create another protocol to achieve this.

The type has been made concrete by the fact that ID has been specified as Int in the protocol. You cannot conform to the protocol without having Int as the type for ID. So saying it can only be used as a generic constraint makes no sense in my opinion as the type cannot change (as I see it) when the associated type has been specified.

I cannot get your error to show up Compiler Explorer

Is your code different from the one you pasted here? Maybe the diagnostic is just out of date, try compiling your project again

It was the wrong question. I've edited the question to reflect the correct question. Sorry!

I don't know why it doesn't work with current swift, but it will work in the next version of swift, probably thanks to SE-0309

you can try it with the nightly version of the compiler