I was hoping this code would compile, but it does not:
protocol A {
associatedtype T
}
protocol B: A where T == Int {
}
var demo: B? = nil
I get the usual error: Protocol 'B' can only be used as a generic constraint because it has Self or associated type requirements. Is this error logically necessary in the same way as it is for fully fledged PATs? Or is the code above perfectly well-defined, and the compiler is simply lacking the necessary implementation?
There was a related discussion here a few weeks back. I believe that this is an implementation limitation—this sort of construct would fall out naturally as a consequence of generalized existentials, there just hasn't been enough development effort focused in that area to allow your example to compile.
Is anyone working on a proposal? I am willing to write - or to help write - the proposal. With @anthonylatsis help in the implementation and his experience in this issue, I’m positive we could finally fix this agitating behavior of the generics system.
Hi guys (@filip-sakel, @anthonylatsis), I just wanted to poke you both with regard to this feature because it came up again in my work just now, and I'll breath such a sigh of relief when this feature is eventually deployed. I myself am totally swamped with coding items on my todo list so I understand entirely that you guys may not have the time, but I just want to express the gratitude that I'll have if you do end up implementing it!