~Copyable protocols

I'm confused on an error message I'm seeing with the following code:

protocol Alpha<B>: ~Copyable {
    associatedtype B: Beta
}

protocol Beta: ~Copyable { // `'Self' required to be 'Copyable' but is marked with '~Copyable'
    associatedtype A: Alpha<Self>
}

What is it about Alpha that is requiring Beta to be Copyable in this case?

1 Like

I think protocol Alpha<B> is implicitly protocol Alpha<B: Copyable>. IIUC, the compiler put Copyable in everywhere you don't explicitly make it ~Copyable.

Edit: Nope. I wasn't considering it's a primary associated type. Something more subtle.

The error message could be clearer, but I believe what you're running up against here is that currently associated types cannot be made ~Copyable.

5 Likes

ah. i hadn't realized that was the case. then there's not some logic about Copyability that i was missing, it's just an (as yet) unimplemented compiler feature?